4 ms·
There's actually a solid argument for "tabs for indentation, spaces for alignment", which solves both for preference and vertically aligning stuff: [tab]void
by menssen 9y ago
There's actually a solid argument for "tabs for indentation, spaces for alignment", which solves both for preference and vertically aligning stuff:
[tab]void someNiceMethod(
[tab][space*20]int arg1
[tab])
But it basically requires having some visual indicator of what is a tab, which most people don't like.
(edited for line breaks)
- rplnt 9y agoI like how it is in Sublime (2) - it shows whitespace characters on highlight.
- IshKebab 9y agoThat's pretty nice. VSCode has a pretty good option too that shows whitespace except single spaces between non-whitespace characters.
- 0xffff2 9y agoI have visual whitespace turned on in all of my text editors. The massive amount of mixed tabs/spaces and trailing whitespace I find in virtually every document with multiple authors leads me to believe that I'm the only person on the planet who actually cares about whitespace at all.
- mark-r 9y agoTrailing whitespace drives me batty! The only reason I can come up with for it is sloppiness.
- emddudley 9y agoIf a system requires thought and care to be used properly then people will inevitably use it improperly. Even skilled, thoughtful people make mistakes or get fatigued and take shortcuts. It seems to me that using tabs for indentation and spaces for alignment is a fragile technique. It's easy to make a mistake and not even notice. If you don't fix that mistake fast, people start to assume that maybe it's OK to ignore whitespace formatting issues. And so the problem compounds. I would prefer to use a system that creates a "pit of success" so that even careless people have a hard time doing it wrong. I think sticking to just one whitespace character is better than mixed tabs and spaces, but best of all is using an editor that can automatically format your code.
- menssen 9y agoWhat I didn't say in my original comment is that I don't actually do this for exactly the reason you describe, and that I think spaces-only is the most robust solution. That said, all you would need is editors to enforce "any line with spaces before a non-whitespace character must have exactly the same number of tabs as the previous line." Which would not be all that difficult, but currently (afaik) does not exist.