Reputation: 18541
Using clang-format with default settings, the following:
if ((exprA) &&
(exprB))
turns into:
if ((exprA) && (exprB))
I'm trying to prevent the collapsing the conditions into a single line, with no success.
Is there currently a way to achieve this?
In clang-format documentation, the BreakBeforeBinaryOperators
parameter seems the closest to what I'm after:
BreakBeforeBinaryOperators (BinaryOperatorStyle)
The way to wrap binary operators.
- BOS_None (in configuration:
None
) Break after operators.
But it seems to kick in only when wrapping is required (column limit is exceeded), which isn't the usual case.
Upvotes: 28
Views: 6150
Reputation: 6143
According to Clang 10 document, your request can be done. You have to do these two changes into your clang file
BraceWrapping:
set AfterControlStatement: true
.ColumnLimit: 1
output -: if ((exprA) &&
(exprB))
You can try this at Here If you have any doubt. but problem is your other codes will also be formatted.
There is no way to split only if ((exprA) && (exprB))
. It can be done if anyone can create a patch for that but creating a patch for this is not so much easy. It takes a lot of time and energy.
Upvotes: 3