Configure Vim for Python

Vim is very beautiful editor for various programming languages. This blog provide details for configuring Vim as a Python IDE on Linux Based Operating Systems.

All the installation commands are performed through Terminal (CTRL+ALT+T  on Ubuntu)

Install Vim with the below:

sudo apt-get install vim

Create below directory structure in the user’s home directory (cd $HOME) in the terminal.

.vim -> bundle

Below contents should be inserted in “.vimrc” file in user’s home directory:

“”””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

set nocompatible
filetype off

set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

” let Vundle manage Vundle
” required!
Bundle ‘gmarik/vundle’

” The bundles you install will be listed here
Bundle ‘scrooloose/nerdtree’
Bundle ‘davidhalter/jedi-vim’

filetype plugin indent on

” The rest of your config follows here.

augroup vimrc_autocmds
autocmd!
” highlight characters past column 120
autocmd FileType python highlight Excess ctermbg=DarkGrey guibg=Black
autocmd FileType python match Excess /\%120v.*/
autocmd FileType python set nowrap
augroup END

” NerdTree Shortcut.
map <F2> :NERDTreeToggle<CR>

” automatically change window’s cwd to file’s dir
set autochdir

” Prefer spaces to tabs
set tabstop=4
set shiftwidth=4
set expandtab

“””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””””

Save the file.

Execute “vim” command and type “:BundleInstall”. All the plug-ins will be installed.

To view the list of plug-ins, open “vim” and type “:BundleList”.

Leave a comment