

Spaces or Tabs? - els

Do you use real tabs or spaces for tabs when you write code?  If spaces, how many?
======
yan
Tabs. It drives me nuts to see people use spaces for everything.

Tabs are there for exactly that purpose. If you want your code to line up
properly, just comment on how wide your tabwidth is, and the reader of the
code will adjust accordingly. Or indent in a tab-independent fashion.

I like my tabwidth set to 3 or 4. It makes code easier to read for myself. I
can't stand it when I open a GNU project and it looks like someone threw up
brackets all over my screen. This wouldn't happen if GNU didn't use an awkward
mix of previously-assumed-8-spaces-wide tabs and spaces to indent their code.

~~~
els
I started this out of a spirited conversation between my boss and I. We've
been using tabs for years; the argument being that anyone can adjust their tab
width to whatever they prefer. As Daniel said, in theory this works but in
reality it never allowed for circumstances where you'd need to indent
something an odd (or if your tabwidth was odd, even) number of spaces. For
example, check out Google's style guide for C++: [http://google-
styleguide.googlecode.com/svn/trunk/cppguide.x...](http://google-
styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Function_Calls#Function_Calls)
You can't format those function arguments like that using tabs. This kind of
granularity is essential, especially working in a team environment.

~~~
yan
For lining up arguments like that, (esp with long objc calls), I use spaces
after indenting to the level the code is indented. For instance,

    
    
      [\t]int val = 0;
      [\t]callSomeFunction(someOtherVal,
      [\t].................val);
    

Anywho, it's a religious argument with no right answers. I was just justifying
my preference.

~~~
moosecake
I prefer the same but it's a pain to line it up manually like this. I usually
settle for vim's = operator, but that has the frustrating behavior of using as
many tabs as possible (according to your tabstop) until using a few spaces. I
can't find any way to change this; anyone know of a vim plugin to circumvent
it?

------
anigbrowl
Tabs...though in a way I don't think code files should have any whitespace in
them; in my ideal world the disk file would be packed and the programmer's
editor would use your preferred code beautification, just like syntax
highlighting. Obviously that would be a hassle if you didn't use a contextual
editor but I question the ongoing importance of that option.

------
DanielStraight
Four spaces except html/css where I use two.

------
jacquesm
I'd like to use tabs, unfortunately pythons 'significant whitespace' mess
makes me have to use spaces instead. To make sure I stay clean I've configured
things such that I can actually see the spaces.

Especially with cutting and pasting sample code this is a total pain.

The interesting part is that many samples in python tutorials have their
spacing messed up so that the samples don't work the way they're intended.

Python is a great little language, but this really keeps tripping me up.

------
icey
Spaces. 4.

------
ErrantX
python 4 spaces

anything else (php, c++, html, etc.) tabs

------
knv
4 spaces in python otherwise tab

------
byoung2
Tabs

