/home/shakir

Enable vim code (Python) auto complete

Posted on 27 Dec, 2007, categorized under Information Insemination



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.. :)

Tags: ,




Looking for something else? Search Google.

5 Responses to "Enable vim code (Python) auto complete"

1 | Arthur Khakimov

February 6th, 2008 at 2:25 pm

Avatar

I 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”)

2 | shakir

February 6th, 2008 at 11:33 pm

Avatar

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

3 | Arthur Khakimov

February 7th, 2008 at 1:25 am

Avatar

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?

4 | What a beard » Blog Archive » links for 2008-02-11

February 12th, 2008 at 9:13 am

Avatar

[...] Enable vim code (Python) auto complete | /home/shakir (tags: vim python) [...]

5 | Xray99

May 22nd, 2008 at 9:03 pm

Avatar

Ur missing a bracket in your Code:

if has(”autocmd”)
autocmd FileType python set complete+=k/path/to/pydiction isk+=.,(
endif ” has(”autocmd”)

Comment Form


  • si perda: wah.. boleh kasi need for speed test power skali... boleh layan network race ni...
  • Faiz: wah....harganya berapa?
  • shakir: Hmm, I have no lab and that actually was my living room :D Sure I'll move them to one of my available rooms at home and make it a lab, but that'll be
  • peja: whoaaa..at least u have ur own lab...look interesting!
  • Qing Ru: He looks really cute! Fatherhood must have been quite rewarding :)
  • shakir: Chris: Thanks, I've updated the post.
  • shakir: tak cukup banyak guinea pig yang dah try and comment on the wimax service, and so I'll just wait :D
  • shakir: Vadim: Yup, but I prefer to just install dosbox and play the game rather than re-installing my system with 32 bit Linux :D
  • Vadim: 2shakir: wine doesn't support 64-bit linux. You have to use 32-bit linux if you want to use wine.
  • kevler: yerp ...dalam 2 hari nih jer ..aku dah kesan 2 BMW X6 , kat puchong dan jalan ampang ..giler laa lawa



Disclaimer

The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my own personal opinion. Inappropriate comments will be deleted at the authors discretion. All code samples (if any, ever) are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Personal (Blogs) - TOP.ORG