Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Possible Duplicate:
Why do some languages recommend using spaces rather than tabs?

While reading over the style guides for PHP

  1. PSR-0
  2. PSR-1
  3. PSR-2

I noticed the rule

Code MUST use 4 spaces for indenting, not tabs.

I'm tabs person, I prefer the faster editing that comes with using tabs.

But given that the language or markup doesn't require spaces instead of tabs (ala YAML), why force spaces which are more time consuming to edit?

share|improve this question

marked as duplicate by Joachim Sauer, Yannis Rizos Jan 21 '13 at 17:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Because I'm a Ruby programmer and Matz says "two spaces"... –  thorsten müller Jan 21 '13 at 17:21
Your premise is wrong: There is no advantage in editing speed. Every useful editor under the sun (well, except nano, if I'm not missing anything) can be configured to replace tabs with spaces as you type. (And aside from that, editing speed is a fallacy; reading speed is more important as code is read more often than it is written.) –  delnan Jan 21 '13 at 17:31
Because they're nazis. Tabs allow you to view code in any tab-widths you want. Freedom baby! Freedom for all! –  MrFox Jan 21 '13 at 18:08
add comment

1 Answer

Because not all programmers (even on the same project) can agree what the size of a tab is. Some set it to the indent size (e.g. 4). Others like to set it to the defacto-standard of 8. If spaces are used, it doesn't matter what your/their setting for tab-width is.

share|improve this answer
That, however, is something I never got. If you don't use tabs for indentation, what ARE they used for in a code editor? And if they aren't used for anything, why not set it to the team's common width? –  Avner Shahar-Kashtan Jan 21 '13 at 17:19
I've been on many projects where the style guide specifically called for tab stops to be every X characters. I have been on much fewer where all the developers actually followed it, especially on code that has been handed down for years and worked on by multiple developers. –  jwernerny Jan 21 '13 at 17:25
This. PSR is a coding style, it's only intention is consistency. 4 spaces for indenting may not be everyone's cup of tea, but consistency is more important than personal preference. –  Yannis Rizos Jan 21 '13 at 17:33
When you use tab's it's cool for all. Everyone see the number of spaces he wants(if he can set up his editor) –  RiaD Jan 21 '13 at 19:42
@RiaD Then you end up with inconsistent line wrapping (too long or too short), since line lengths are specified in absolutes (N characters) while tab stops are flexible. –  Brian Marshall Jan 21 '13 at 22:22
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.