Deprecate tabs for indenting (was Re: Indenting with tabs vs spaces)

Courageous jkraska at
Wed Dec 5 12:03:39 EST 2001

>>Works like a charm. Just never forget to install python-mode.el ;)

>Which means the editor is replacing each tab level with 4 spaces,
>so there are no tabs in your code. Works for me too.

For vim users:

set softtabstop=4 
set shiftwidth=4 
set et
set showmatch
set matchtime=1
set lcs=tab:»\ 
set list

The lcs=tab: line should be typed like this:

set lcs=tab:<ctrl-V>187\

Note that the normal tabstop is left alone at 8. This gives the python
writer using vim the following:

Each time you press tab, it moves you to the closest tabstop of 4 by
inserting just enough spaces to get you there. When hard tabs are
present, they align on an 8 character boundary and appear with the
ascii character 187 (the "small double greater than character"). This
makes tabs show up like a sore thumb, which is important in Python.
You'll likewise find it helpful for MAKE.

Note that since you are getting spaces every time you type tab, when
using make and occasionally other systems you'll eventually need a
REAL tab. You get this by typing <ctrl-v>TAB.

It took me a while to figure out (with the helpful advice of someone
here or in the editors group) to use 8 character stops for real tabs.
But it really is the way to go, particularly if you are on a unix
system, where any variety of programs (lpr, cat, more, et al) will
treat your tabstops as 8 characters by default.

Note that Python treats your tabstops as 8 characters by default, so
this will always make DEDENT syntax errors obvious as well.


More information about the Python-list mailing list