vscode格式化c代码

参考链接:
Clang-Format 用法详解
https://blog.csdn.net/wan212000/article/details/131709197


# 左花括号后面不换行
BreakBeforeBraces: Attach
# 缩进
IndentWidth: 4
# 行宽,不自动换行
ColumnLimit:  0

在设置界面,Extensions > C/C++ > Formatting中设置
最小更改
VSCode默认
Clang_format_fallback_Style:Visual Studio不变,
Clang_format_style:file, 默认不变

Use file to load the style from a .clang-format file in the current or parent directory, or use file:<path>/.clang-format to reference a specific path. Use {key: value, ...} to set specific parameters. For example, the Visual Studio style is similar to: { BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Allman, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }.

另外在settings.json中增加 else后不换行

"C_Cpp.vcFormat.newLine.beforeElse": false

在git diff editor中,忽略空白字符,(这个做的没有idea系列好,idea可以忽略中间位置的空白字符)

"diffEditor.ignoreTrimWhitespace": true,

设置后格式化代码如下

        if (is_xx) {
            xxstop();
        } else {
            xxstop();
            i++;
            printf("%d....\n", i);
        }
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值