vscode將默認格式化的if、while等大括號在下改為大括號在右的方法


打開設置,搜索C_Cpp: Clang_format_style

 

將 { BasedOnStyle: LLVM, IndentWidth: 4 } 填入即可

 

附常用格式化內容:

#基於那個配置文件
BasedOnStyle: LLVM
#指針的*的挨着哪邊
PointerAlignment: Right
#縮進寬度
IndentWidth: 4
# 連續的空行保留幾行
MaxEmptyLinesToKeep: 1
# 在 @property 后面添加空格, \@property (readonly) 而不是 \@property(readonly).
ObjCSpaceAfterProperty: true
# OC block后面的縮進
ObjCBlockIndentWidth: 4
# 是否允許短方法單行
AllowShortFunctionsOnASingleLine: true
# 是否允許短if單行 If true, if (a) return; 可以放到同一行
AllowShortIfStatementsOnASingleLine: true
#注釋對齊
AlignTrailingComments: true
# 換行的時候對齊操作符
#AlignOperands: true
# 中括號兩邊空格 [] 
SpacesInSquareBrackets: true
# 小括號兩邊添加空格
SpacesInParentheses : true
#多行聲明語句按照=對齊
AlignConsecutiveDeclarations: true
#連續的賦值語句以 = 為中心對齊
AlignConsecutiveAssignments: true
#等號兩邊的空格
SpaceBeforeAssignmentOperators: true
# 容器類的空格 例如 OC的字典
SpacesInContainerLiterals: true
#縮進
IndentWrappedFunctionNames: true
#在block從空行開始
KeepEmptyLinesAtTheStartOfBlocks: true
#在構造函數初始化時按逗號斷行,並以冒號對齊
BreakConstructorInitializersBeforeComma: true
#函數參數換行
AllowAllParametersOfDeclarationOnNextLine: true
#括號后添加空格
SpaceAfterCStyleCast: true
#tab鍵盤的寬度
TabWidth: 4
UseTab: Never

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM