I am trying to get clang-format to leave if-statements with one statement on the same line.
Example input:
if(is_finished) break;
if(foo) {
// do something
}
clang-format output:
if(is_finished)
break;
if(foo) {
// do something
}
Wanted output:
if(is_finished) break;
if(foo) {
// do something
}
None of the space related options seem to match this style.
current config:
---
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: ForIndentation
SpaceBeforeParens: Never
BraceWrapping:
AfterControlStatement: false
The relevant config option is AllowShortIfStatementsOnASingleLine
.
The choices are:
Never
WithoutElse
Always
https://clang.llvm.org/docs/ClangFormatStyleOptions.html
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