Here is the VIM .vimrc file that I use to work with Python.
set nu
set ts=4
set sw=4
set sts=4
set autoindent
set smartindent
set expandtab
set smarttab
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,
except,finally,def,class
autocmd BufWritePre *.py :%s/\s\+$//e
It will
- Display the line number.
- Set tab stop to 4.
- Enable you to use < and > to indent or unindent a block in visual mode.
- Insert spaces instead of tab, when pressing the tab button.
- Automatically indent the next line after this keywords: if, elif, else, for, while, try, except, finally, def, class.
- Remove all trailing spaces during exit.

I’ve been meaning to try using vim instead of NetBeans for Python editing. You just gave me a bit of a boost. Thanks!
What is the use of Python? I mean, what do you use it for?
@Hadi: Python is an interpreted programming language that runs on Windows, Linux/Unix, Mac OS X.
@Eric Wendelin: I am glad to hear that.
What is the use of writing programs in this language instead of using other programming languages or scripting languages?
Is it faster? Is it specific for some topics?
http://www.python.org is a good place to read for answers to your queries!
- Paddy.
@Paddy3118: You are absolutely right.
Some tips here on an improvement to your setup, namely making it automatically indent up to the parens inside long argument lists (the way PEP8 says one should). The script is here, put it in ~/.vim/indent and remember to “set filetype indent on” (or “set filetype indent ftplugin on” if you use that other post’s ftplugin trick).
@David: Thanks. I will have a look.
Also be sure to “set nosmartindent” as described in the recent update to David’s link. Keeping smartindent on if you have filetype indent support on is redundant, and only causes problems (e.g. shoves all comments to the left because it thinks they’re #include statements). Filetype indenting really is much nicer than smartindent, allowing its plugins to provide much more custom python (or whichever other language you are using) support instead of a generic set of hardcoded rules (like smartindent or cindent).