How can I realize the following indentation after access modifiers:
class A{ public: int a; }
should result in
class A { public: int a; // note the indentation }
clang-format only allows the access modifiers to be on the same level as the int a
AccessModifierOffset: 0
resulting in
class A { public: int a; }
Where I work, we've stumbled upon the same problem. Since the IndentWidth
parameter controls the indentation everywhere (classes, functions, etc.) what you're trying to achieve seems impossible. The next best thing, in my opinion, is to keep IndentWidth=4
and set AccessModifierOffset=-2
. That way you get:
class Foo { public: Foo() = default; }; bool foo() { return true; }
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