Jedi is an auto-completion library for Python code that I’ve so far really enjoyed using in vim. It’s able to analyze your code (and anything you import) to guess what you mean when you invoke it (Ctrl+Space by default). Out of the box with jedi-vim, the configuration requires a bit more keypressing than I’m generally happy with, so I used Supertab as suggested. It’s advanced enough to know the types of your variables and the argument names for your function calls. I’ve included instructions below that should get you up and running fast.
- If you don’t already use it, configure pathogen.vim:
- Get pathogen:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim - Only do this if you don’t have an existing vimrc file:
echo "syntax on
filetype plugin indent on" > ~/.vimrc - Add pathogen to your .vimrc file:
sed -i '1i\
call pathogen#infect()' ~/.vimrc
- Get pathogen:
- Install jedi-vim and jedi:
cd ~/.vim/bundle/; \
git clone git://github.com/davidhalter/jedi-vim.git; \
cd jedi-vim; \
git submodule update --init - Install Supertab:
cd ~/.vim/bundle/; \
git clone git://github.com/ervandew/supertab.git - Configure Supertab:
echo 'let g:SuperTabDefaultCompletionType = "context"' >> ~/.vimrc
- Optional: Disable auto-complete on
.
(bothers me, up to you)
echo 'let g:jedi#popup_on_dot = 0' >> ~/.vimrc
At this point, you can begin to type a member of a library and hit <Tab>
to automatically suggest ways to finish (or just type <Tab>
after a .
to show all available options).
Thanks for the detailed info! Do you know of any problems between jedi and python-mode (which uses rope)?
Hi memilanuk, thanks for the feedback. I’ve not used python-mode before, but unless it does autocompletion, you shouldn’t have trouble if you install it via pathogen. Let me know if you have success with it.