How to indent after access modifiers with clang-format

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;
}

Leave a Comment