Skip to content

[clang-format] array initializer one per line #61533

@abdelmaged

Description

@abdelmaged

I'd like to format array initializer to be one item per line, instead of all items in one line.

Example

I want this:

static char *categories[] = {
  "Alpha",
  "Beta",
  "Gamma",
  "Delta",
  "Epsilon",
  "Zeta"
};

Not this:

static char *categories[] = {"Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta"};

There has been multiple question on stackoverflow with no way to achieve this:
https://stackoverflow.com/questions/69537052/clang-format-array-initializer-one-per-line
https://stackoverflow.com/questions/38058627/clang-format-array-initialisers
https://stackoverflow.com/questions/39144255/clang-format-removes-new-lines-in-array-definition-with-designators
https://stackoverflow.com/questions/75572012/clang-format-designated-initializer-one-member-per-line

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang-formatquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions