Thanks for your feedback, and I appreciate the link and the logic behind
Unfortunately, by stripping all trailing whitespace, clang-format has made
a policy decision, but with no way to control it via the configuration. I
understand it's not desirable for every option to be configurable, but this
is something which significantly affects existing code. I propose that it
would be good to have an option "TrailingWhitespace:
Truncate>Preserve>Fix". Truncate would be existing behaviour. Preserve
would not alter leading whitespace on blank lines or touch trailing
whitespace. Fix would fix leading whitespace on blank lines, fix trailing
whitespace on code, but avoid making any changes in comments except if it
was reflowed. It could be more granular but that's where I'd start.
## Some objective problems:
- Existing code which is indented this way would require a lot of changes.
That's true for any project starting to use clang-format. That's why we'd
suggest to use editor and version control system integrations and only
format the lines that are touched.
- Markdown (which is useful in comments) is sensitive to trailing
I haven't seen a project using markdown in comments and relying on the
trailing whitespace. However, even if some do, I think it'd be better for
clang-format to recognize this and not remove spaces for those comments
It's possible to add a post process script to normalise leading whitespace
but not trailing whitespace (e.g. in the case of markdown).
## Some subjective problems:
- It's my preference when I start editing on a line, the indentation is
How often do you even start editing in a currently empty line? Don't you
normally start with some existing code and have to insert a line break?
clang-format wouldn't help there..
(It's also a really easy habit to loose once you have gotten yourself to
rely on clang-format working in your editor).
- When moving cursor up and down it's my preference that it doesn't jump
back and forward when crossing blank lines.
But the proposal wouldn't really change much here, unless you happen to
have the cursor right at the start of the line and it would all be indented
the exact same level. Isn't that a really rare case?
Some of these issues can be fixed by editor configuration/plugins, but it's