Scott Penrose


Scott is an expert software developer with over 30 years experience, specialising in education, automation and remote data.

Tabs, 2 space, 4 space, 8 space, 9.5 spaces...

I get asked why I use Tabs. I am very fussy when it comes to code layout. Preferences for indentation, use of brackets etc are all very important. But I also like to leave people choices.

There are lots of arguments on using spaces vs tabs and how many to use. I am not really going to get into them, but I did want to give an example of what should and should not be set.


These rules are good:

  • Any naming standard is better than no standard.
  • There is no "one true" standard, we all have our preferences
  • If there is standard already in place, use it. Don't create another standard or muddy the existing standards.

An example

What font size should you use. Well 9 point. Everyone should use 9 point. This is of course not true. Firstly, everyone should use the font and size to suit them. And secondly screens size change, available space and point size change (depending on what you use for calibration).

So you should give the user the choice of font, background colour, colour syntax highlighting etc.

I believe the same things for spacing of indentations.

Back when I used 21" monitor and used the full width of my screen, I really like 8 spaces for a tab. Now I prefer the more acceptable 4 spaces. But sometimes, when working with XML or Javascript I find that 2 is even appropriate.

Use Tab, configure Spacing

So I use tab. Then I set tab to 4 spaces on my normal computer. And then when another developer in my team prefers 2 spaces there is no down side.

See Also

  • Coding