I'm using clang-format with a fairly minimal configuration file, and I'm not very familiar with the options. For the sake of the question, consider this piece of unformatted code:
int msgResult = ShowMBox(R_MESSAGE, msgText, MB_OK_ENABLE | MB_CANCEL_ENABLE, MB_STYLE_ERROR);
When I run clang-format on this snippet, I get
int msgResult
= ShowMBox(R_MESSAGE, msgText, MB_OK_ENABLE | MB_CANCEL_ENABLE, MB_STYLE_ERROR);
But I'd prefer
int msgResult = ShowMBox(R_MESSAGE, msgText, MB_OK_ENABLE | MB_CANCEL_ENABLE,
MB_STYLE_ERROR);
Is there a way to enforce not breaking after =
, or at least prefer not to?
I believe you want these two style options:
BinPackArguments: true
AlignAfterOpenBracket: Align
Without BinPackArguments
, clang-format will try to either put all function arguments on one line, or if it can't will put one function argument per line. Most of the pre-defined styles already set BinPackArguments
to true
, but the Mozilla
style does not.
Without AlignAfterOpenBracket
set to Align
, clang-format will sometimes prefer to put all arguments on the second line, rather than just a single argument that doesn't line up with the other arguments. Most of the pre-defined styles already set AlignAfterOpenBracket
to Align
, but the WebKit
style does not.
See the documentation for more details about these settings.
My testing was done with clang-format 6.0.0. Perhaps you had an earlier version that didn't support all this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With