Function editing with Vim throws IndentError

Thomas Troeger thomas.troeger.ext at siemens.com
Fri Jul 25 11:00:44 CEST 2008


Lawrence D'Oliveiro wrote:
> Specified by whom? The most common setting these days is 4 columns.

Where? I've randomly seen code snipplets that indent using spaces or, 
worse, tabstop != 8, but most code I've come across uses tabstop width 
8, which is how it was meant to be from the beginning of time.

Unfortunately, for many people it's hard to understand that a tabstop is 
not the same as indenting with spaces, but I think this is leading too 
far and will end in a dogmatic discussion like the `ViM vs. Emacs' war.

Anyways, if you claim tabstop 4 is most widely used I'd like to see some 
kind of a reference for that since it contradicts not only my experience.

Finally, I'd like to throw in this one from the Linux kernel sources, 
from `Documentation/CodingStyle:

------------------------------------------------------------------------ 

			Chapter 1: Indentation

Tabs are 8 characters, and thus indentations are also 8 characters.
There are heretic movements that try to make indentations 4 (or even 2!)
characters deep, and that is akin to trying to define the value of PI to
be 3.

[...]

Now, some people will claim that having 8-character indentations makes
the code move too far to the right, and makes it hard to read on a
80-character terminal screen.  The answer to that is that if you need
more than 3 levels of indentation, you're screwed anyway, and should fix
your program.

In short, 8-char indents make things easier to read, and have the added
benefit of warning you when you're nesting your functions too deep.
Heed that warning.
------------------------------------------------------------------------ 



More information about the Python-list mailing list