Saturday, September 12, 2015

Vim AutoCompletion for Python

Installing Pydiction to enable Auto-Completion for Python in Vi (Vim) editor:
1. First install Pathogen using the System Package Manager.
2. Download vimogen int the home directory using command-line:
 git clone
3. Create .vim and .bundle directories by command-line:
 mkdir ~/.vim
 mkdir ~/.vim/bundle
4. Create file .vimogen_repos with the following content:
 echo "" > ~/.vimogen_repos
5. Run vimogen by command-line:
  ~/vimogen/   (and type 1 to install) 
  This will install pydiction in directory ~/.vim/bundle/
5. Under ~.vim do the following link:
  cd ~/.vim
  ln -s bundle/pydiction/after .
6. edit ~/.vimrc file and add the following lines:
filetype plugin on
let g:pydiction_location = '~/.vim/bundle/pydiction/complete-dict'
if has("autocmd")
  autocmd FileType python set complete+=k/path/to/pydiction iskeyword+=.,(
endif " has("autocmd")

That all you need to do. 
Now open an existing or new *.py file and check auto-completion by typing any python keyword or module partially and press tab to show the available choices.
For further reading check the following links.