Monday, February 29, 2016

Auto-completion for Python + Vim

By default, in Vim, one can do Ctrl + P, Ctrl + N, that will do autocompletion based on existing keywords that we have typed in the document.
One can use pydiction, which have a predefined dictionary of autocomplete words. For this method, we can autocomplete sklearn modules, but not variable name like the first case.
Also, we would like to autocomplete file path as well.

It seems YouCompleteMe is a good package for this, even though setting it up is very time consuming. I still don't know what make it work. Suggestion is to follow this link and reinstall vim and python
http://www.oschrenk.com/vim-youcompleteme-and-python/

brew install vim
brew install python

Also, add a line in ~/.vimrc
Bundle 'Valloric/YouCompleteMe'
then open vim and run
":BundleInstall"

Then follow the guide on YouCompleteMe github.
These links are helpful
https://github.com/Valloric/YouCompleteMe#user-guide
http://susu.github.io/posts/clang-completion-in-vim-with-youcompleteme/
http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/
https://news.ycombinator.com/item?id=5169062

PS: This could be the ultimate guide
https://blog.dbrgn.ch/2013/5/27/using-jedi-with-ymc/

No comments:

Post a Comment