4 ms·
This is why you use tabs for indentation and spaces for alignment. Too bad most editors don't have good support for that.
by nhaehnle 9y ago
This is why you use tabs for indentation and spaces for alignment. Too bad most editors don't have good support for that.
- imron 9y ago> Too bad most editors don't have good support for that. And this is why you use spaces for everything.
- abritinthebay 9y ago... and get the worst possible experience? No thanks.
- recursive 9y agoIt can't be the worst experience if things actually line up.
- abritinthebay 9y agoI was being flippant but... things actually line up if you force everything to tabs too (or “smart tabs” if you really really want alignment for some reason). Except with tabs everyone gets whatever width they want. Tab width is configurable system wide (and even in GitHub’s terrible web view). Spaces are objectively worse in every possible way and require workarounds and editor hacks to make them behave like tabs. Skip a step & just use tabs: much better.
- recursive 9y agoIt's only objective if you're controlling the objectives. Here's my counter-example. Go here in a browser: https://github.com/id-Software/Quake-III-Arena/blob/master/code/ui/ui_players.c#L28 https://github.com/id-Software/Quake-III-Arena/blob/master/c... Note that the use of tabs has caused un-alignment. You've claimed that tab width is configurable in git's web view, but I can't figure out how to do it. And further, if it requires me to configure in a certain way, then it's not really true that "everyone can configure tabs how they want". Spaces. Set it and forget it. Works everywhere, every time. Objectively better.
- dkonofalski 9y ago>Objectively better. You can't really say that definitively without ignoring the laundry list of negatives that come with spaces. Spaces are not configurable at all. That, in itself, is reason enough that Tabs are "objectively better".
- abritinthebay 9y agoThat’s due to the spaces tho, not the tabs. It’s the lines that used spaces that look awful. You literally provided me with more proof spaces are bad. Good example.
- recursive 9y agoNope, it's the tabs. The only lines that are mis-aligned are mis-aligned because of tabs, not spaces. And it is a good example.
- abritinthebay 9y agoI see the exact opposite but.. k.
- recursive 9y agoInteresting. Perhaps you've been using spaces all along, but somehow they appear to be tabs to you. What a twist that would be.
- megaman22 9y agoOr you just configure your editor to output spaces when you hit the tab key. Any serious text editor or IDE these days should have that option.
- dimman 9y agoUse tabs for indentation and spaces for alignment and you will never have any problems using whatever tab width you want (except for potentially exceeding 80 char line length if you care about that. IMO that's secondary compared to the pros.)
- aerique 9y agoAlso too bad both tabs and spaces are usually displaced as the same whitespace, which is a problem for humans. This, too, can be fixed in most editors.
- RobertRoberts 9y agoI recently found the answer for this. Sublime [0] with the Elastic Tabs[1] plugin[2]. [0] https://www.sublimetext.com/ https://www.sublimetext.com/ [1] http://nickgravgaard.com/elastic-tabstops/ http://nickgravgaard.com/elastic-tabstops/ [2] https://github.com/SublimeText/ElasticTabstops https://github.com/SublimeText/ElasticTabstops
- u801e 9y agoOr just don't bother with alignment and just use tabs for indentation. For example, instead of aligning function parameters after the opening parenthesis, move them to the next line and use a hanging indent: someType someFunctionName( param1, param2, ...) { statement1; statement2; ... } I find that following a style like this will work equally well with tabs or spaces and that I have to spend less time formatting code I write (either manually or changing a setting in the editor I'm using).
- nhaehnle 9y agoThis is a very good point, and I agree. No matter how you do it[0], alignment is bad for maintainability. It happens that someType or someFunctionName changes, and if you use alignment, you'll have to re-align all those parameters. This is annoying to do even with editor help, and it generates noisy diffs which make patch review needlessly more difficult. Aligning the names of member variables is even worse. Just Say No to alignment, perhaps? ;) [0] Well, except if you use "elastic tabs", which don't have widespread support in the first place.