Clang-format格式标准化

1,工具与准备:

VS code中可以安装clang-format扩展或者使用C/C++;

   

2,配置VS code

设置中,首选项->设置; 可使用everythin搜索clang-format.exe; 一般visual studio会自带,选择一个即可(在环境变量中,添加对应的路径);

   

   

3,配置 .clang-format

中断使用以下命令创建 .clang-format文件(内容编码为UTF8或UTF8 BOM),否则容易报错

clang-format-style=llvm -dump-config> .clang-format

   

建议配置

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

BasedOnStyle: LLVM

ColumnLimit: 120

IndentWidth: 4

TabWidth: 4

UseTab: Never

SpaceBeforeParens: ControlStatements

SpaceBeforeAssignmentOperators: true

SpaceAfterTemplateKeyword: true

SpaceAfterCStyleCast: true

SpaceBeforeCStyleCastParentheses: true

SpacesAroundRangeBasedForLoopColon: true

SpaceBeforeRangeBasedForLoopParentheses: false

SpacesInContainerLiterals: true

BreakStringLiterals: true

BreakBeforeBraces: Linux

   

posted @ 2024-09-08 19:42  理想是书店店长  阅读(148)  评论(0)    收藏  举报