相关疑难解决方法(0)

Clang格式换行符

我正在寻找一个clang-format设置来防止该工具删除换行符.

例如,我将我的ColumnLimit设置设置为120,这是我重新格式化一些示例代码时会发生的情况.

之前:

#include <vector>
#include <string>

std::vector<std::string> get_vec()
{
   return std::vector<std::string> {
      "this is a test",
      "some of the lines are longer",
      "than other, but I would like",
      "to keep them on separate lines"
   };
}

int main()
{
   auto vec = get_vec();
}
Run Code Online (Sandbox Code Playgroud)

后:

#include <vector>
#include <string>

std::vector<std::string> get_vec()
{
   return std::vector<std::string>{"this is a test", "some of the lines are longer", "than other, but I would like",
         "to keep them on separate lines"}; …
Run Code Online (Sandbox Code Playgroud)

c++ code-formatting clang clang-format

45
推荐指数
4
解决办法
1万
查看次数

标签 统计

c++ ×1

clang ×1

clang-format ×1

code-formatting ×1