Python Indentation and Vim

Annika Backstrom
in misc, on 22 March 2008 (history)

Python's syntax relies on indentation for statement grouping. The convention is to use spaces, but I've always found tabs to be easier to work with in vim. My largest gripe: if I mis-tabbed, I had to press "delete" four times to erase all the spaces I created. Turns out, that needn't be the case: vim can detect multi-space indentation and delete one "tab" at a time.

Here are some good resources I found while digging into this:

  1. Secrets of tabs in vim
  2. Notes on using Vim and Python -- check out the autoindentation based on file name, just below the main table
  3. Converting tabs to spaces

Bonus: check out vimrc in the python "Vim" folder for other helpful files.