5 ms·
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 comme
by yan 17y ago
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.
- DanielStraight 17y agoIn theory, I agree. In practice, this is too much effort in my mind for the benefit you get out of it.
- humbledrone 17y agoI 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?
- els 17y agoI 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.xml?showone=Function_Calls#Function_Calls 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.
- yan 17y agoFor 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 17y agoI 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?
- CyberFonic 17y agoI 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.