4 ms·
Why do different tab settings result in inconsistent formatting? Surely it always inserts a \t into the file. Seems to me the only way it's inconsistent on-disk
by dTal 7y ago
Why do different tab settings result in inconsistent formatting? Surely it always inserts a \t into the file. Seems to me the only way it's inconsistent on-disk is if those people are actually writing spaces (and not agreeing on how many). If you're not going to agree on an indentation width, surely tabs are superior? Conversely, if you're going to mandate an indentation width, surely it's just as easy to do that with tabs as with spaces - and more flexible?
- jasode 7y ago>Why do different tab settings result in inconsistent formatting? Because some programmers also use tabs for cosmetic alignment. (The other thread also illustrates some examples.) It doesn't matter if that's semantically incorrect. A lot of it has to do with muscle memory; the programmer's brain is on automatic pilot and therefore the left pinky finger just taps <tab><tab> ... to line up function parameters or the values of variables. This type of alignment is not always round-trip perfectly preserved with code formatting utilities that covert tabs->spaces->tabs. (In other words, some programmers sometimes presses <tab> not for its semantic meaning but as a mechanical shortcut to quickly move the cursor to the right an arbitrary amount.) One can make an airtight case for the rational purity of tabs but the problem is that the real world doesn't always want to cooperate.
- scrollaway 7y agoIn the real world, there's people who benefit from the accessibility of tabs. It's not that hard to avoid alignment (which most devs recommend against for other reasons such as maintenance costs and git diff noise), I've been doing so for fifteen years without issues.
- ithkuil 7y ago> the reality is that the default setting in Visual Studio is that the tab key inserts 4 spaces I don't use VS so I'm not sure about this specific example, but from my experience, if you have to fight all your colleagues' editor defaults, you're going to have a hard time.