4 ms·
Why not both? Tabs can do something that spaces cannot do: they can provide unambiguous indentation information. To this end, it's braindead easy: for every
by snowfarthing 2y ago
Why not both?
Tabs can do something that spaces cannot do: they can provide unambiguous indentation information. To this end, it's braindead easy: for every tab, you have a new indentation level.
But spaces can do something that tabs cannot do: they can provide formatting info that remains constant regardless of tab size. Thus, once your indentation is correct, you can use spaces to make sure that one-per-line arguments for that one function are all lined up correctly, or for those comments at the end of a line, that are best lined up together, or if you want to make sure that keys and values are lined up in a hash table -- all these cases are handled nicely by spaces, but are horrendous if you change the tab size.
I have used this for Python, PHP, JavaScript, and HTML, and this is something that works <i>very well</i> with <i>all</i> of these languages. The one place where the formatting won't work out too well would be for variable-font editors -- but perhaps that can be handled by either choosing a fixed font to spite the editor, or to make sure the editor matches the sizes of spaces to the sizes of the characters above the previous line.
Or, alternatively, the editor could interpret mid-line tabs as formatting, too, and just align them up according to the longest line, but that would require editor shenanigans that I think are currently not provided for!