我正在寻找一种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();
}
后:
#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();
}
我想要的是该工具会中断超过 120 个字符的行,但不会仅仅因为它们少于 120 个字符而决定合并行。
有这样的选择吗?文档中的任何内容对我来说都没有什么突出的。