I have an array of structs:
(assume that the identifiers are #define
d somewhere else…)
typedef struct { int a; char id[2+1]; } T; const T T_list[] = { { PRIO_HOUSE, "HI" }, { PRIO_SOMETHING_ELSE, "WO" } // ... }
I would like clang-format to format it like this:
const T T_list[] = { { PRIO_HOUSE , "HI" }, { PRIO_SOMETHING_ELSE, "WO" } // ... }
Is it possible?
I already read the docs, but I didnt find something helpful in this regard. https://clang.llvm.org/docs/ClangFormatStyleOptions.html
This is my .clang-format
--- BasedOnStyle: WebKit BreakBeforeBraces: Allman BraceWrapping: AfterEnum: false IndentCaseLabels: 'true' AlignConsecutiveAssignments: 'true' AlignConsecutiveDeclarations: 'true' AlignEscapedNewlines: 'true' AlignTrailingComments: 'true' AllowShortFunctionsOnASingleLine: 'false' #...
Answer
No. clang-format
cannot do this.
The way I do it is:
- use a third party tool to align it
- before the formatted region put:
//clang-format off
- after the formatted region put:
//clang-format on