Beginning version 7 of vim, it has this nice auto completion feature. It is by default however limited to words that has already been in the current workspace. To use it, simply press [ctrl] +n or [ctrl] + p key while in edit mode. For example:

We can however *teach* vim to autocomplete a whole bunch of other stuffs as well, by using something so called Dictionaries. With this idea we can have auto completion for Python, Ruby, PHP, Bash, and any other programming languages code.
For an example, let's try to install Python dictionary, by downloading it from here:
http://www.vim.org/scripts/script.php?script_id=850
The next thing to do is to extract the downloaded file to the appropriate folder:
shakir@herugrim ~ $ mkdir ~/.vim shakir@herugrim ~ $ tar xvzf pydiction-0.5.tar.gz -C ~/.vim
and add this lines to your ~/.vimrc (be sure to replace "/home/shakir" to your own home directory)
if has("autocmd")
autocmd FileType python set complete+=k/home/shakir/.vim/pydiction-0.5/pydiction isk+=.,(
endif " has("autocmd"
and let's see the result:

Browse around the Vim script page and your customized Vim could be just as good if not better than some IDEs..
I have imported this post to my other site and maintain it there.
14 Comments on this post
Leave a CommentI can’t understand why but this doesn’t work for me:
“C:\Program Files\Vim\vim71\dic\python is a place where pydiction resides.
if has(“autocmd”)
autocmd FileType python set complete+=k/$VIMRUNTIME\dic\python\pydiction isk+=.,(
endif ” has(“autocmd”)
Comment left on 2.6.2008 by Arthur Khakimov
have you tried complete+=k/”C:\Program Files\Vim\vim71\dic\python\dic\python\pydiction” …., and surely place pydiction at C:\Program Files\Vim\vim71\dic\python\dic\python\pydiction .
I’m guessing as i’m not using windows myself, but maybe you can try and report how it goes
Comment left on 2.6.2008 by shakir
Yes, Shakir, I tried that as well, but no luck
.
This python autocompletion feature is only working if I set in _vimrc:
—–
set dictionary=$VIMRUNTIME\dic\python\pydiction
—–
I then can call autocomplete by consecutive pressing Ctrl+x and Ctrl+k. But in this way, as far as I understand, the pydiction is called for any file type, and in anyway it is not working by just pressing Ctrl+n or Ctrl+p.
More ideas?
Comment left on 2.7.2008 by Arthur Khakimov
[...] Enable vim code (Python) auto complete | /home/shakir (tags: vim python) [...]
Ur missing a bracket in your Code:
if has(“autocmd”)
autocmd FileType python set complete+=k/path/to/pydiction isk+=.,(
endif ” has(“autocmd”)
Comment left on 5.22.2008 by Xray99
For Windows paths use: complete+=kC:/Vim/pydiction-0.5/pydiction
where C:/Vim/pydiction-0.5/ is the folder containing the pydiction file.
Comment left on 1.23.2009 by M
Thanks M:
It’s working.
Comment left on 3.24.2009 by Vincent Lin
Nice!
Comment left on 3.29.2009 by Qnix
Wow, that’s very nice. Didn’t know this auto complete feature. Thanks a lot.
Comment left on 6.27.2009 by CTS GmbH
Could you update your post for the pydiction-1.2. I can’t seem to get it work.
If I type :help ftplugin, i get to see the help for the plugin… But it seems to not find the
complete-dict. I am using vim 7.1.138 on ubuntu hardy.
Comment left on 9.7.2009 by binom
Thanks to your article I could setup pydiction!
Cheers
Comment left on 10.7.2009 by Kenny Meyer
binom, read the readme file inside the zip
Comment left on 10.14.2009 by bahodir
“I am using vim 7.1.138 on ubuntu hardy.”
You can out more?
Comment left on 12.15.2010 by biocheamou
[...] to ask it to link to an empty db, or to switch to db lists with F8 for instance thanks — ref http://www.mohdshakir.net/2007/12/27…-auto-complete Attached [...]