NotePublic/Software/Applications/Clang/Clang_Format_自定义风格.md

2.9 KiB

Clang Format 自定义风格

BasedOnStyle: Google
AccessModifierOffset: '-1'
AlignAfterOpenBracket: Align
AlignEscapedNewlines: Left
AlignOperands: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'false'
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'true'
BinPackParameters: 'false'
BreakBeforeTernaryOperators: 'true'
BreakArrays: 'false'
CompactNamespaces: 'false'
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeBinaryOperators: NonAssignment
BitFieldColonSpacing: Before
# AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
  Enabled: 'true'
  AcrossEmptyLines: 'false'
  AcrossComments: 'false'
AlignConsecutiveBitFields:
  Enabled: 'true'
  AcrossEmptyLines: 'false'
  AcrossComments: 'false'
AlignConsecutiveDeclarations:
  Enabled: 'true'
  AcrossEmptyLines: 'false'
  AcrossComments: 'false'
AlignConsecutiveMacros:
  Enabled: 'true'
  AcrossEmptyLines: 'false'
  AcrossComments: 'false'
AlignTrailingComments:
  Kind: Always
  OverEmptyLines: 2
BreakBeforeBraces: Custom
BraceWrapping:
  AfterCaseLabel: 'true'
  AfterClass: 'true'
  AfterStruct: 'true'
  AfterControlStatement: Always
  AfterEnum: 'true'
  AfterFunction: 'true'
  AfterNamespace: 'true'
  AfterObjCDeclaration: 'true'
  AfterUnion: 'true'
  AfterExternBlock: 'true'
  BeforeCatch: 'true'
  BeforeElse: 'true'
  BeforeLambdaBody: 'true'
  BeforeWhile: 'true'
  IndentBraces: false
  SplitEmptyFunction: 'true'
  SplitEmptyRecord: 'true'
  SplitEmptyNamespace: 'true'
InsertBraces: 'true'
AllowAllArgumentsOnNextLine: 'true'
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: 'true'
ColumnLimit: '80'
ContinuationIndentWidth: '4'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentPPDirectives: None
IndentWidth: '4'
Language: Cpp
MaxEmptyLinesToKeep: '1'
NamespaceIndentation: None
PointerAlignment: Left
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesBeforeTrailingComments: '2'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'true'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Cpp11
TabWidth: '4'
UseTab: Never

外部参考资料

  1. Clang 18.0.0git documentation