Penguin
Note: You are viewing an old revision of this page. View the current version.

PerryLorier and his ReligiousWar

Tabs should be 8 characters and no correspondance shall be entered into. While that's stupidly wide, at least it's a standard. There is absolutely nothing worse than opening a file and having it look like it was formatted by a two year old chimpanzee on crack.

But vim/emacs support mode lines so you can see which tab width you use!

Except that

  1. they don't agree on the syntax, so you need two sets of modelines, one for each application
  2. grep/patch/diff/sed/lpr/less don't read modelines.

You can run things through a preprocessor to convert tabs to the correct number of spaces!

A converted diff does not apply as a proper patch anymore. A converted MakeFile bombs out due to a "missing delimiter". A converted sendmail.cf means no mail is delivered.

You can tell Vim/Emacs/etc to always expand tabs to spaces

Some people may tell you to do something like

:set tabstop=8 :set shiftwidth=4

in Vim (and analogous in Emacs). Backspace for unindent doesn't work anymore then. You remove one space, not one tab.

But they push my code too far to the right

Then your logic is too complicated. Break it into another function to simplify it.


The correct answer is to use 8 character tabs. Sure they are wider than they need to be, but they work. Anyone who tries to tell you that tabs should be whatever else they feel like (2? 4? 5? 6?) needs to be shot. Especially if they ever think that their code is going to be viewed by anyone else, so unless you are writing a proprietary program and never planning on giving the code away or ever showing it to anyone, don't change the tab size.

Of course, if everyone just used python then it wouldn't matter.

Meanwhile, AristotePagaltzis? rests in nirvana

You can use 4 character tabs and feel fine all along. More importantly, so will the people who open your files.

The key to this state of mind is simple: don't use tabs ANYWHERE but the beginning of the line!!

Well, people can throw a monkey wrench in this scheme if they use overly smrt(sic) editor( setting)s so tabs are used for 8 character gaps and spaces create smaller indentations. Unfortunately, way too many people think this is a good idea and way too many tools support and even suggest this style. This is utterly stupid.

ONLY use tabs to indent.
ONLY use tabs at the beginning of a line.
ONLY use spaces to line up things in the middle of a block.

Then you can choose your tab width whichever way you like and noone will ever be the wiser from looking at your files.

Have a nice day.