March 2, 2013

Python friendly .vimrc

syn on
let python_highlight_builtins=1
au FileType python setlocal expandtab shiftwidth=4 softtabstop=4 colorcolumn=80 ai nu nowrap cul

let python_highlight_builtins=1 enables coloring of reserved and built in functions in Python. It is going to make you aware when a variable name overrides a built in function (e.g. id or type). For details on other specific parameters see Python's wiki page on vim and "Secrets of tabs in vim."

To enable folding add:

set foldmethod=indent

and you can open a fold with zo, close with zc, close all in the document with zM or open with zR.

To emulate PyCharm's variables highlighting under the cursor try this command:

:autocmd CursorMoved * exe printf('match Search /\V\<%s\>/'escape(expand('<cword>')'/\'))