gpt4 book ai didi

c++ - 停止 clang-format 在 VS Code 中将元素拆分为多行

转载 作者:行者123 更新时间:2023-12-02 10:28:00 24 4
gpt4 key购买 nike

当我使用 clang-format 作为自动格式化程序在 VS Code 中键入一个 vector 时,它会将每个元素拆分到它自己的行上,如下所示:

#include <vector>

using namespace std;

int main()
{
vector<int> v = {1,
2,
3,
4,
5};
}
我想要什么是让它保持这样的状态:
#include <vector>

using namespace std;

int main()
{
vector<int> v = { 1,2,3,4,5 };
}
我查看了所有的 clang 格式设置,但找不到任何改变它的东西。

最佳答案

AllowAllArgumentsOnNextLine (bool)

If a function call or braced initializer list doesn’t fit on a line, allow putting all arguments onto the next line, even if BinPackArguments is false.


这应该是真的。
还增加 ColumnLimit https://clang.llvm.org/docs/ClangFormatStyleOptions.html

关于c++ - 停止 clang-format 在 VS Code 中将元素拆分为多行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63449004/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com