VScode c/c++代码格式化配置

1.下载C/C++ 插件

image

2.按“ctrl + ,”打开设置


3.搜索“clang_format_style”


4.填入格式信息

{ 
  BasedOnStyle: LLVM, 
  IndentWidth: 4, 
  BreakBeforeBraces: Custom, 
  BraceWrapping: { 
    AfterFunction: true, 
    AfterControlStatement: false 
  }, 
  AllowShortFunctionsOnASingleLine: false, 
  ColumnLimit: 180, 
  AllowShortIfStatementsOnASingleLine: true, 
  AlignConsecutiveMacros: true,
  AlignConsecutiveAssignments: true,
  AlignTrailingComments: { 
    Kind: Always, 
    OverEmptyLines: 0
  }
}
posted @ 2026-03-14 23:14  自由的Charles  阅读(40)  评论(0)    收藏  举报