I'm trying to format a C file with clang-format. I want indentations to be two space characters, which mostly works except for in global variable struct initialization. For this, it continues to produce lines which are indented with four spaces.
Here is my .clang-format file
BasedOnStyle: LLVM
ColumnLimit: '80'
IndentWidth: '2'
clang-format produces this surprising output
typedef struct {
int x;
} foo;
static foo bar{
1, // This line is being indented with 4 spaces!
};
And this is what I'd expect the file to look like:
typedef struct {
int x;
} foo;
static foo bar{
1, // This line is being indented with 2 spaces!
};
I've tried using a few different values for ConstructorInitializerIndentWidth
, but that field doesn't appear to affect this pattern.
Is there a setting that I could provide to get this behavior?
question from:
https://stackoverflow.com/questions/65650849/clang-format-struct-initialization-indent-with-two-spaces 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…