I'm using BreakBeforeBraces: Allman
in my .clang-format
file, but braces in control statements (such as if
, for
, while
, ...) are not being put on their own line.
// Currently:
void foo()
{
while(true) {
bar();
}
}
// What I want:
void foo()
{
while(true)
{
bar();
}
}
I've read that you can set nested configuration classes for braces in BraceWrapping
, but I could't figure out the correct YAML syntax (and JSON syntax for the sublime text plugin), and couldn't find any existing example.
Is there any way of doing this?
Short answer: YES. The clang-format tool has a -sort-includes option. Changing the order of #include directives can definitely change the behavior of existing code, and may break existing code.
clang-format supports two ways to provide custom style options: directly specify style configuration in the -style= command line option or use -style=file and put style configuration in the . clang-format or _clang-format file in the project directory.
Clang-Format is a widely-used C++ code formatter. As it provides an option to define code style options in YAML-formatted files — named . clang-format or _clang-format — these files often become a part of your project where you keep all code style rules.
Achieving the desired result with a specific combination of style options is impossible at the moment. I've reported the issue as bug 25069.
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