I am primarily a Python programmer and have finally ditched the IDE in favour of vim and I will admit, I am loving it !

My vimrc file looks like this:

autocmd BufRead,BufNewFile *.py syntax on
autocmd BufRead,BufNewFile *.py set ai
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
set tabstop=4
set expandtab
set shiftwidth=4
filetype indent on

Any changes I should make to make my Python vim experience more pleasant?

  • \$\begingroup\$ Hi Henry, welcome to the site. This really isn't a question for Code Review though, as this site is for reviewing working code. It is most likely better on Stack Overflow. \$\endgroup\$ – Mark Loeser Feb 21 '11 at 19:53
  • \$\begingroup\$ why would this be offtopic? this is working code \$\endgroup\$ – Erich Apr 16 '20 at 8:20

I like to add the following:

" Allow easy use of hidden buffers.
" This allows you to move away from a buffer without saving
set hidden

" Turn search highlighting on
set hlsearch

" Turn on spelling
" This auto spell checks comments not code (so very cool)
set spell

" tabstop:          Width of tab character
" expandtab:        When on uses space instead of tabs
" softtabstop:      Fine tunes the amount of white space to be added
" shiftwidth        Determines the amount of whitespace to add in normal mode
set tabstop     =4
set softtabstop =4
set shiftwidth  =4
set expandtab
  • \$\begingroup\$ Wonderful! Any suggestions for must-have vim plugins for enhanced Python support? \$\endgroup\$ – user1761 Feb 16 '11 at 19:34
  • \$\begingroup\$ @Henry You don't want to miss pyflakes (on-the fly syntax error reporting) and using pep8 as a compiler to see if you comply with the python style guide (PEP8). See my vim cfg files at (github.com/lupino3/config), it is fully commented and there also are some useful vim plugins. \$\endgroup\$ – Andrea Spadaccini Feb 21 '11 at 16:58