-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Description
| Bugzilla Link | 18441 |
| Version | trunk |
| OS | All |
| Reporter | LLVM Bugzilla Contributor |
| CC | @kevincox |
Extended Description
I'd love to see an option to clang-format that would allow blank lines to be indented to the same level as the lines surrounding them (at the same scope). Currently clang-format will always remove all indentation from otherwise empty lines. This interferes with text editing by requiring manual insertion of tab/indentation characters when later editing the code to add additional lines.
Take this simple example:
int foo(int a)
{
int b = a + 2;
return b + 2;
}
When typing this code initially many editors will automatically add indentation characters on the empty line to match the indentation of the line above it. clang-format currently strips out this indentation. I later decide to change this function to:
int foo(int a)
{
int b = a + 2;
b++;
return b + 2;
}
If the indentation of the blank line still matches the indentation of the line above it I can just click the mouse on the blank line and type the code. If the indentation is stripped I have to manually indent the new line of code. I'd really prefer to just keep the indentation characters automatically inserted by my text editor there always.
I'd like to see an option to clang-format to allow these blank lines to maintain their indentation. My team and I find indented blank lines more convenient to work with. Additionally, such an option would avoid thousands of unnecessary changes/diffs if we ran our entire (fairly large) source code base through clang-format.