25 October 2010

Vim code tab-completion support for python

Ever felt disappointed when writing codes in Vim but without code completion functionality just like what Eclipse IDE has? Well, Vim 7+ can do auto-completion by default!

In the insert mode (i-mode), when you press [ctrl]+p or [ctrl]+n, vim will try to complete with words that have already appeared in the current file. But that's it, that is the default.

To make vim even smarter, we have to teach him how to complete other words. The idea is using 'dictionaries'. Fortunately, some guys out there have already developed plugins (for code completion) for certain programming languages. Here I am going to show you vim plugin support for python.

First, download the plugin package (pydiction) from here:

http://www.vim.org/scripts/script.php?script_id=850

Second, unpack the package and basically put files inside ~/.vim directory.

Third, if you are downloading pydiction 1.0+, just follow the installation instructions in the README.txt inside the package, or read instructions from the link listed above. However if you are downloading packages below 1.0, then follow instructions here:

http://tinyurl.com/balbal

Now you can do tab-completion for python codes! This tool should accelerate your programming speed in Vim. Try it and stop complaining!

No comments: