5 ms·
We really shouldn't get into this, but I can't help myself. - Every single text editor that's come after notepad.exe has had automatic tab/space conversion. Pr
by Zikes 11y ago
We really shouldn't get into this, but I can't help myself.
- Every single text editor that's come after notepad.exe has had automatic tab/space conversion. Pressing tab inserts N spaces, pressing backspace un-indents N spaces, etc.
- In some languages, this is not a feature. 2-character tabs, using two tabs to indent for alignment:
var myVar = 1,
otherVar = 2,
anotherVar = 3;
Opened later in an editor using 4-character tabs:
var myVar = 1;
otherVar = 2,
anotherVar = 3;
- {}[]<> and more aren't used for anything close to their original literary intent.
- oneeyedpigeon 11y agoTabs should never be used for lining things up, for that very reason. In your example, you've stopped 'indenting' and started 'aligning'. And it's only 'working' because "var " % 2 == 0; other language keywords will screw that up.
- Zikes 11y agoSounds to me like you're saying there's no objectively correct answer that works for all languages and situations, which I agree with.
- scrollaway 11y agoThere... is, actually. If you don't actually attempt to align the variable names, then what you're doing is "indenting items in a list", essentially. In general, you should avoid aligning unless the readability gains are significant. Aligning things means that you end up re-aligning when you add or remove longer items. This increases maintenance and pollutes diffs (which also means code reviews and git logs).
- jahewson 11y agoMy editor aligns things for me - no effort at all.
- scrollaway 11y agoYou are creating effort for the people who review your code. On their behalf, please stop, it's tedious.