Issue 126543
Summary clang-format: add option to preserve indentation-only whitespace lines
Labels clang-format
Assignees
Reporter seanm
    Unless I'm missing it, clang-format has no option to keep whitespace-only lines that keep indentation level with the code.

The bullets represent spaces. I'm looking for a way to *not* have the indentation-only line 3 be changed:

```c
if (true) { 
••••int myNum = 2;
••••
••••myNum = 4;
}
```

Always becomes:

```c
if (true) { 
••••int myNum = 2;

••••myNum = 4;
}
```

Xcode has an option (default I think) to create/preserve such indentation, in Xcode > Settings > Text Editing > Editing:

```
While Editing:  ☑ Automatically trim trailing spaces  
                          ☑ Including whitespace-only lines
```

Xcode's "re-indent" command also adds such indentation, and so all my code has such indentation, hence I'd like clang-format to not touch it.

(I've seen others want the same, ex: https://stackoverflow.com/questions/32619716/clang-format-is-removing-all-the-indent-spaces-on-my-empty-lines)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to