If you configure your editor to drop spaces when you hit 'tab', then the file is guaranteed to look the same for everyone, and stops being context-dependent-- a bad thing for plain text, IMO.
If you configure your editor to drop spaces when you hit 'tab', then the file is guaranteed to look the same for everyone, and stops being context-dependent-- a bad thing for plain text, IMO.
This will keep the vertical alignment regardless of the preferred width of the tab.
int f() {
int someVariableName = myFunctionCall(expr(5), // <--- line A
somethingElse(9), // <--- line B
a_long * expression + involving(multiple.subExprs));
int d = somethingElse; // <-- line C
}
...you're saying line A is indented with tabs, and line B with spaces? Because that will misalign if your tab setting isn't the same.Or are you saying that both A and B are indented with spaces? Then what about line C, which will misalign with A and B if your tab stop is a different width?
Or do we indent the entire body of f() with spaces, and then in that case you're basically using spaces everywhere, which the good idea that sparked this whole thing?
/*t*/int f() {
/*tabs*/int someVariableName = myFunctionCall(expr(5), // <--- line A
/*tabs*//*--------------spaces--------------*/somethingElse(9), // <--- line B
/*tabs*//*--------------spaces--------------*/a_long * expression + involving(multiple.subExprs));
/*tabs*/int d = somethingElse; // <-- line C
/*t*/} int f() {
<tab> someVariableName = myFunctionCall(
<tab><tab> expr(5),
<tab><tab> somethingElse(9),
<tab><tab> a_long * expression + involving(multiple.subExprs)
<tab> );
<tab> d = somethingElse;
} 1 int f() {
2 >---int someVariableName = myFunctionCall(expr(5),
3 >--- somethingElse(9),
4 >--- a_long * expression + involving(multiple.subExprs));
5 >---int d = somethingElse;
6 }
Tabs only for indentation (lines 2 to 5), spaces for alignment (lines 3 and 4). This is easy to achieve if you use Vim with Smart Tabs for instance (https://vim.sourceforge.io/scripts/script.php?script_id=231).B is indented with a tab, plus the requisite number of spaces to line up with the above line.
C is indented with a tab.
Hm,... that could actually be a feature! Adding inertia. Not that I would use that, but it makes me think..^^
Soft tabs FTW.
(F#, where indentation matters, and Clojure using Parinfer where indentation matters to get the form placement correct both make tab characters horrible to use.)
If I was working on a project where there was a strong preference for indenting assignments, or any other case like this, I would use spaces throughout.
silly js devs and their var block...