Why I prefer no tabs in source code

New! I notice several people have been referred to this page from http://derkarl.org/why_to_tabs.html, which tries to counter my arguments against tabs. (I also notice that the author rather ungracefully failed to inform me of the page's existence, thereby conveniently not giving me a chance to respond. Kind of makes his rather immature "I win again" comment a bit hollow ...) Well, he raises some interesting points, but fails to address some of mine. Or maybe he just didn't understand them, which is probably my fault, because I admit that some of the arguments below aren't worded in a particularly clear way. When I get some time, I'll attempt to fix this, and respond to his article with some concrete examples which clarify what I mean.

Anyway, back to the original page...

Many people intermingle hard tabs (ASCII 09) with spaces in their source code, rather than using n spaces in the place of a single tab, where n is usually 8. It's a matter of personal taste, but here's why I don't believe this is a good idea in general. (I say `in general' because there are always exceptions -- in my opinion the following applies especially to free software because in the bazaar model of development, code exposure is very high. However, if for example you are unfortunate enough to be working for a company which leaves none of its employees any choice as to their code indentation style and editor, then well ... this document is irrelevant anyway :-)

What do you think?

I'm always interested to hear other people's views on this. Are there other reasons I've missed? Or perhaps you'd like to try to convince me I'm wrong! I'm an open-minded person, so if you can argue the opposite case strongly enough, I'll change this page and my coding habits. Otherwise...

Do the world a favour! Put this in your ~/.emacs:

  (setq-default indent-tabs-mode nil)

or this in your ~/.vimrc:

  :set expandtab

(Someone please tell me how this can be achieved in other editors.)

Other people's views, and feedback so far

The demi-god Linus has his own, rather er, religious views, some of which I agree with.

Dawn Endico has pointed out that Jamie Zawinski of Netscape/Mozilla fame has also written a web page on this topic which presents a similar argument to mine, but in a different way. Well worth a look. Thanks Dawn!

New! Someone who didn't give his name sent me a whole bunch of related links. I'm relieved to see that these pages mostly agree with me :-)

New! Robert Swindell pointed out an excellent proposal called PT/SC whereby formatting parameters (e.g. tab width) are stored in the header of a plain text file using a common, humanly-readable syntax. Thanks Robert. Let's hope that editors implement support for this soon ...

Browser independent HTML! Valid CSS! Valid HTML 4.0!

Last updated: Sun May 2 12:54:37 2004
© 1995-2003 Adam Spiers <adam@spiers.net>