An auto-indenter could easily detect the idiom if hit backspace after the auto-indent it produced after the first 'if'.
Once you have your two ifs at the same indent, the indenter can use that info to keep them at the same indentation level. It could even assume you mean (a&&b) vs (!a&&!b) and not the three-way (a&&b), (a&&!b), (!a) when you follow it with an else block (I think that would be the best heuristic)
Implementing this will get a bit hairy, but if you are writing an auto-indenter for C, you should be used to that.
So, all you would have to do is hit one extra backspace to signal your intent.
Alternatively, one could type
if(a) if(b) {
To signal that one wants
if(a)
if(b) {
Same number of keystrokes, and, IMO, that space is slightly easier to type than the return it replaces.
calebegg|12 years ago
Someone|12 years ago
Once you have your two ifs at the same indent, the indenter can use that info to keep them at the same indentation level. It could even assume you mean (a&&b) vs (!a&&!b) and not the three-way (a&&b), (a&&!b), (!a) when you follow it with an else block (I think that would be the best heuristic)
Implementing this will get a bit hairy, but if you are writing an auto-indenter for C, you should be used to that.
So, all you would have to do is hit one extra backspace to signal your intent.
Alternatively, one could type
To signal that one wants Same number of keystrokes, and, IMO, that space is slightly easier to type than the return it replaces.