加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

VScode格式化代码风格(大括号)设置

(2021-01-15 16:01:52)
分类: C/Cpp
关于VScode设置大括号格式的做法,设置路径:
File->Preferences->Settings->Extensions->C/C++->c_Cpp: Clang_format_fallback Style

默认是visual code说明:
Name of the predefined style used as a fallback in case clang-format is invoked with style "file" but the .clang-format file is not found. Possible values are Visual Studio, LLVM, Google, Chromium, Mozilla, WebKit, none, or 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 }

更改为Linux,即大括号在某些情况下在右侧不换行
{ BasedOnStyle: LLVM, UseTab: Never, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Linux, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4 }

设置好之后使用"Ctrl+Shift+F"格式化代码


用于大括号换行样式。
可能的值有:
BS_Attach (在配置中: Attach) 总是将大括号与上下文连在一起。
BS_Linux (在配置中: Linux) 像Attach一样, 但是在一个方法、命名空间或一个类定义的大括号之前换行
BS_Mozilla (在配置中: Mozilla) 像Attach一样, 但是在一个枚举、方法或记录定义前换行。
BS_Stroustrup (在配置中: Stroustrup) 像Attach一样,但是在方法定义、catch、和else前换行
BS_Allman (在配置中: Allman) 总是在大括号之前换行。
BS_GNU (在配置中: GNU) 总是在括号前中断,并添加一个额外的级别的缩进到控件语句的括号中,而不是类、函数或其他定义的括号中。
BS_WebKit (在配置中: WebKit) 像Attach一样, 但是在方法前换行。
BS_Custom (在配置中: Custom) 在“BraceWrapping”里配置每一个单独的大括号。

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有