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... You can't format those function arguments like that using tabs. This kind of granularity is essential, especially working in a team environment.
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.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?
Re:Spaces or Tabs?
by CyberFonic on Friday October 02, 2009 @09:41PM
(#858363)
I used to be an all tabs guy(sw=4, ts=4). Then I got hooked on Python and it was easier to go with the spaces only. Have configured my .exrc so that tabs get mapped to spaces (4 / tabstop). I don't even think of it any more. All my old C sources have morphed into spaces only as a result. Hey, disks have become huge and text compression is pretty efficient so I don't lose sleep over it anymore.
Re:Spaces or Tabs?
by humbledrone on Friday October 02, 2009 @02:56PM
(#857731)
I can't agree with you for one simple reason: I have never seen a file that exclusively uses tabs for indentation. There are always a few spaces accidentally thrown into the mix, and therefore, as you mentioned, the user has to know the tabwidth. Doesn't forcing the user to use your tabwidth defeat the whole purpose of using tabs?
Re:Spaces or Tabs?
by DanielStraight on Friday October 02, 2009 @02:38PM
(#857680)
In theory, I agree. In practice, this is too much effort in my mind for the benefit you get out of it.
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.