Pages

Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts

Tuesday, August 17, 2010

Vim 7.3 Released

On 16 August 2010, I had received an email from Vim google mailing list, this mail announce that Vim 7.3 was released to public finally. You can check below quote for release note by Bram Moolenaar.


Hello Vim users,

Announcing:  Vim (Vi IMproved) version 7.3

This is a minor release of Vim.  It consists of Vim 7.2 plus all
patches, updated runtime files and some more, see below.  It has been
two years since the 7.2 release, thus it's not that "minor".  But not
"major" either.  Something in between, don't know how to call that.

The most notable additions since 7.2:
- Persistent undo and undo for reload
- Blowfish encryption, encryption of the swap file
- Conceal text
- Lua interface
- Python 3 interface

Once you have installed Vim 7.3 you can find all the details about the
changes since Vim 7.2 with:
        :help version-7.3

Gratitude
---------

If you like Vim, this is the way to say thanks:
http://iccf-holland.org/clinic.html

Where to get it
---------------

The best way to obtain the latest Vim 7.3 is using Mercurial.
Summary:
        hg clone https://vim.googlecode.com/hg/ vim
        cd vim/src
        hg update vim73
        make
More information here: http://www.vim.org/mercurial.php

All downloadable files can be found below this directory:
        ftp://ftp.vim.org/pub/vim/

Direct link to the MS-Windows self-installing executable:
        ftp://ftp.vim.org/pub/vim/pc/gvim73.exe

Information about which files to download for what system:
        http://www.vim.org/download.php

A list of mirror sites can be found here:
        http://www.vim.org/mirrors.php

UNIX:
unix/vim-7.3.tar.bz2           sources + runtime files, bzip2 compressed

MS-WINDOWS one-size-fits-all:
pc/gvim73.exe                  installer for GUI and console executables,
                               includes all runtime files, many features

VARIOUS:
doc/vim73html.zip              help files converted to HTML

MS-WINDOWS separate files:
pc/vim73rt.zip                 runtime files
pc/gvim73.zip                  GUI binary for Windows 95/98/NT/2000/XP
pc/gvim73ole.zip               GUI binary with OLE support
pc/gvim73_s.zip                GUI binary for Windows 3.1 (untested)
pc/vim73d32.zip                console version for MS-DOS/Windows 95/98
pc/vim73w32.zip                console version for Windows NT/2000/XP
pc/vim73src.zip                sources for PC (with CR-LF)

DIFFS TO PREVIOUS RELEASE:
unix/vim-7.2-7.3.diff.gz               sources + runtime files
unstable/unix/vim-7.3f-7.3.diff.gz     sources + runtime files

Omitted in this version are:
- Extra and lang archives, these are now included in the main source
  and runtime archives.
- The 16-bit DOS, OS/2 and Amiga versions, these are obsolete.

Mailing lists
-------------

For user questions you can turn to the Vim mailing list.  There are a
lot of tips, scripts and solutions.  You can ask your Vim questions, but
only if you subscribe.  See http://www.vim.org/maillist.php#vim

If you want to help Vim development, discuss new features or get the
latest patches, subscribe to the vim-dev mailing list.  See
http://www.vim.org/maillist.php#vim-dev

Subject specific lists:
Multi-byte issues: http://www.vim.org/maillist.php#vim-multibyte
Macintosh issues:  http://www.vim.org/maillist.php#vim-mac

Before you ask a question you should search the archives, someone may
already have given the answer.

Reporting bugs
--------------

Send them to ...@vim.org>.  Please describe the problem precisely.
All the time spent on answering mail is subtracted from the time that is
spent on improving Vim!  Always give a reproducible example and try to
find out which settings or other things influence the appearance of the
bug.  Try starting without your own vimrc file: "vim -u NONE".  Try
different machines if possible.  See ":help bugs" in Vim.  Send me a
patch if you can!

Happy Vimming!

--
Q: Should I clean my house or work on Vim?
A: Whatever contains more bugs.

 /// Bram Moolenaar -- B...@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Tuesday, March 30, 2010

Python in Vim Script

I realized that we could embed python script in vim script. Thus we can do something that vim script can't do but python can.

In windows vim package, vim only supports for python24. But my python version was python26 therefore I needed to recompile vim or if you're too lazy, you could download compiled gvim.exe and vim.exe for python support at http://www.gooli.org/blog/gvim-72-with-python-2526-support-windows-binaries/ and replace your original gvim.exe and vim.exe with them.

Usually in Linux, vim package is already compiled with python support. You can script python in vim script with no time.

To check python already work in vim, you can type command bellow, if you see the message it means python already works well.
:py print "python in vim"
or
:python print "python in vim"

There are 3 ways to include python code in vim script:
  • By using python command for example:
    python import sys
    python sys.argv=["foo", "bar"]
    python print "this's python script"

  • By using marker:
    python << PYSCRIPT
    #python code here sys.argv=["foo", "bar"]
    print "this's python script"
    PYSCRIPT

    In example above I use "PYSCRIPT" as python marker, but you can another tag word for you python script marker.
  • By including file:
    pyfile python-script.py
There are some commands vim provided to communicate between python and vim itself, but here I will explain only 2 of them briefly, those are "vim.command" and "vim.eval". Before using them you need to import vim module in python script. You can import it by adding below line in your python code:
import vim

vim.command is used to execute vim command in python script, for example when I want to turn off syntax color, I will add script below:
vim.command("syntax off")

vim.eval is used to get value of variables in vim script, for example :
let s:test_str = "Just test"
python << PYTHON_SCRIPT
import vim
str = vim.eval("s:test_str")
print str
PYTHON_SCRIPT


You can get more detail information about python in vim script in vim help
:help python

For further example I tried to create simple tags-setter and ctags-generator by reading it from a configuration file, here is the code.

/home/test/tag-cfg:
tag-file=/home/test/tags
src-dir=/home/test/src-code


/vim/test/tag-gen-set.vim:
let s:conf_file = "/home/test/tag-cfg"
pyfile vim_tags_gen_set.py
py gen_and_set_tags(vim.eval('s:proj_file'))


/vim/test/vim_tags_gen_set.py:
import vim

def dir_trim(str):
    if '/' != str[len(str) - 1]:
    str = str + '/'
    return str

def str_trim(str):
    if '\n' == str[len(str) - 1]:
    str = str[:-1]
    return str

def gen_and_set_tags(proj_file):
    # Open file
    f = open(proj_file, "r")

    # Get project file path
    f.seek(13)
    tmp_str = f.readline()
    tmp_str = str_trim(tmp_str)
    project_file = tmp_str

    # Get tag file path
    f.seek(9,1)
    tmp_str = f.readline()
    tmp_str = str_trim(tmp_str)
    tag_file = tmp_str

    # Get source dir
    f.seek(8,1)
    tmp_str = f.readline()
    tmp_str = str_trim(tmp_str)
    src_dir = tmp_str

    # Close file
    f.flush()
    f.close()

    # Set the commands
    cmd_gen_tags = "!ctags -R -f " + tag_file + " " + src_dir + "/*"
    cmd_set_tags = "set tags=" + tag_file

    print cmd_gen_tags
    print cmd_set_tags

    # Execute the commands
    vim.command(cmd_gen_tags)
    vim.command(cmd_set_tags)