【问题标题】:clang-format multiline array definition and ending bracesclang 格式的多行数组定义和结束大括号
【发布时间】:2019-11-14 14:57:14
【问题描述】:

我正在使用 clang-format(通过 VScode),它正在以这种方式重构我的数组定义代码

int my_array[] = {
    OPTION1, 2,
    OPTION2, 4,
    END};

虽然我希望结束大括号转到下一行

int my_array[] = {
    OPTION1, 2,
    OPTION2, 4,
    END
};

我似乎找不到正确的设置。知道我怎么能得到这个吗?

【问题讨论】:

  • 你能显示你当前的 .clang 格式文件吗?
  • 我也不确定你想要的clang格式是否可行

标签: c++ clang-format


【解决方案1】:

可以通过添加// clang-format off来完成

// clang-format off
int my_array[] = {
    OPTION1, 2,
    OPTION2, 4,
    END
};
// clang-format on

但这并不是最优雅的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 2016-08-09
    • 1970-01-01
    • 2021-11-26
    • 2014-11-24
    • 2022-10-19
    • 2012-09-12
    相关资源
    最近更新 更多