In VsCode I would like to change my Clang formatting to :
class Test {
public:
Test() : tmp(0)
{
if (0 == 0) {
std::cout << "hello" << std::endl;
}
}
~Test();
protected:
private:
int tmp;
};
But currently I got :
class Test {
public:
Test() : tmp(0) {
if (0 == 0) {
std::cout << "hello" << std::endl;
}
}
~Test();
protected:
private:
int tmp;
};
My CLang settings :
{ BasedOnStyle: Google, IndentWidth: 4 }
The brace you want to break is after a function, so you would want to add this to Clang setting:
BreakBeforeBraces: Custom
BraceWrapping:
AfterFunction: true
You can find other BraceWrapping options in the Clang-Format Style Options.
At present, Clang provides only an option to adjust modifiers indentation - AccessModifierOffset. This option will offset in or out from the IndentWidth you set. It is not currently possible to make modifier indentation standard. Fortunately, it is currently being discussed and reviewed here.
You can set this to make it less annoying:
AccessModifierOffset: 0
Here is what you get if you set all above options:
class Test {
public:
Test() : tmp(0)
{
if (0 == 0) {
std::cout << "hello" << std::endl;
}
}
~Test();
protected:
private:
int tmp;
};
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