Vim - Add Python autocompletion

By xngo on July 5, 2019

In this tutorial, I will show you how to install jedi-vim plugin so that you will get Python autocompletion in Vim. It would require you to first install the Pathogen package manager and then install jedi-vim.

Install Pathogen

mkdir -p ~/.vim/autoload ~/.vim/bundle
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Configure ~/.vimrc

Add the following lines in ~/.vimrc.

execute pathogen#infect()
syntax on
filetype plugin indent on

Install Jedi

cd ~/.vim/bundle/
git clone --recursive https://github.com/davidhalter/jedi-vim.git

Test autocompletion in Vim

Run vim test.py and then press i to switch to insert mode.

And, type in the code like below to see Python autocompletion in action.

Python autocompletion in action

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.