views:

404

answers:

4

I've noticed that most of the HTML/XML/HAML that gets generated from plugins uses 2 spaces instead of 1 tab. I use textmate and have tabs set to 4 spaces for HAML/HTML/XML and 2 spaces for Javascript/Ruby, but I only have to press the tab key once to get nice indentation. Pressing the space bar twice and delete twice seems like too much work :p.

Do you manually type two spaces, or is some middle layer converting tabs to two spaces? Or do just a few of you use tabs?

+7  A: 

2 spaces is generally agreed-upon.

Ben
is there any reason behind this, for reference? thanks for the answer, I'll start doing that :)
viatropos
Well, since you asked specifically about Rails, I guess I can point to the fact that the Rails codebase itself uses 2 spaces. Since it is such a widely-used and contributed-to codebase, I think we can accept 2 spaces as convention.
Ben
+2  A: 

2 spaces. Even for the plain Ruby kids.

macek
A: 

2 spaces is the convention for Ruby which Ruby on Rails is based upon.

Sean Tan
+2  A: 

In more practical terms, if you use mutliple OS and editors ( such as at work I used RubyMine on Win XP and TextMate on my MacBook at home and one of our developers uses Notepad ++ and another Aptana and we even have one who uses Netbeans, all of these editors interpret tabs differently - different indentation, but 2 spaces are always 2 spaces. Also if you ever use HAML or if you need to copy paste your code into some websites that try to colorcode your code, 2 spaces are essential.

Nick Gorbikoff