Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to align commas in initializer list using clang format?

Tags:

clang-format

For example, if it is possible to format

static const Field field[] = {
    { "c_name", "integer", "not null" },
    { "c_id", "varchar(50)", "not null" },
};

to

static const Field field[] = {
    { "c_name", "integer",     "not null" },
    { "c_id",   "varchar(50)", "not null" },
};

using clang-format?

like image 736
guan boshen Avatar asked Oct 22 '25 00:10

guan boshen


1 Answers

I have searched a lot. The only solution I found is formatting manually. Turn off the clang format, format the code manually and then turn it on using inline comment.

// clang-format off
static const Field field[] = {
    { "c_name", "integer",     "not null" },
    { "c_id",   "varchar(50)", "not null" },
};
// clang-format on
like image 57
guan boshen Avatar answered Oct 26 '25 19:10

guan boshen