Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2 Spaces or 1 Tab, what's the standard for indentation in the Rails Community?

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?

like image 771
Lance Avatar asked Apr 20 '10 21:04

Lance


People also ask

What is the standard tab indent size?

The default value for the tab-size property is 8 space characters, and it can accept any positive integer value.

What is a two space indent?

If you represent the indents using space characters (ASCII SP), then 2 spaces is 2 characters fewer than 4 spaces. If you allow TAB characters to be used, then (on Windows) a TAB indents by up to 4 spaces, so TAB characters result in fewer characters.

How many spaces are needed for indentation?

Standard paragraph indentation is about five spaces or one-quarter to one-half of an inch, depending on which style guide you follow.

What is 4 spaced indentation?

For example if you start off using four spaces for an indent, then you should always use four spaces. In the example below, four spaces have been used for the first indent, but only two for the second, and you can see that as a result the code doesn't “line up”. phrase = input("Talk to me > ")


1 Answers

2 spaces is generally agreed-upon.

like image 146
Ben Avatar answered Sep 18 '22 15:09

Ben