I got the next .clang-format file in my project\'s root directory:
---
AlignTrailingComments: true
AllowShortFunctionsOnASingleLine: false
AllowShortIfStatements
I managed to achieve the effect you want by changing both AccessModifierOffset with IndentWidth. Basically, the first is used as an offset of the second, so if you create your .clang-format like this you get what you want:
AccessModifierOffset: -4
IndentWidth: 8
If AccessModifierOffset is 0, the public keyword would be at the same level of indentation as the members. However, changing IndentWidth will indent all code by 8 spaces, even those outside the class declaration. This is a sample code:
class Foo {
public:
Foo();
virtual ~Foo(); };
int main(int argc, char *argv[]) {
std::cout << "Hello world" << std::endl;
return 0;
}