2023-09-12 12:02:58 +08:00
|
|
|
# Clang Format 自定义风格
|
|
|
|
|
|
|
|
```js
|
|
|
|
BasedOnStyle: Google
|
2023-09-12 18:07:15 +08:00
|
|
|
AccessModifierOffset: '-1'
|
2023-09-12 12:02:58 +08:00
|
|
|
AlignAfterOpenBracket: Align
|
2023-09-12 18:07:15 +08:00
|
|
|
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
|
2023-09-12 14:44:33 +08:00
|
|
|
AlignConsecutiveAssignments:
|
2023-09-12 18:07:15 +08:00
|
|
|
Enabled: 'true'
|
|
|
|
AcrossEmptyLines: 'false'
|
|
|
|
AcrossComments: 'false'
|
2023-09-12 14:44:33 +08:00
|
|
|
AlignConsecutiveBitFields:
|
2023-09-12 18:07:15 +08:00
|
|
|
Enabled: 'true'
|
|
|
|
AcrossEmptyLines: 'false'
|
|
|
|
AcrossComments: 'false'
|
2023-09-12 14:44:33 +08:00
|
|
|
AlignConsecutiveDeclarations:
|
2023-09-12 18:07:15 +08:00
|
|
|
Enabled: 'true'
|
|
|
|
AcrossEmptyLines: 'false'
|
|
|
|
AcrossComments: 'false'
|
2023-09-12 14:44:33 +08:00
|
|
|
AlignConsecutiveMacros:
|
2023-09-12 18:07:15 +08:00
|
|
|
Enabled: 'true'
|
|
|
|
AcrossEmptyLines: 'false'
|
|
|
|
AcrossComments: 'false'
|
2023-09-12 14:44:33 +08:00
|
|
|
AlignTrailingComments:
|
|
|
|
Kind: Always
|
|
|
|
OverEmptyLines: 2
|
2023-09-12 18:07:15 +08:00
|
|
|
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'
|
2023-09-12 14:44:33 +08:00
|
|
|
BreakConstructorInitializers: BeforeComma
|
|
|
|
BreakInheritanceList: BeforeComma
|
2023-09-12 18:07:15 +08:00
|
|
|
BreakStringLiterals: 'true'
|
|
|
|
ColumnLimit: '80'
|
|
|
|
ContinuationIndentWidth: '4'
|
2023-09-12 14:44:33 +08:00
|
|
|
IncludeBlocks: Regroup
|
2023-09-12 18:07:15 +08:00
|
|
|
IndentCaseLabels: 'false'
|
2023-09-12 12:02:58 +08:00
|
|
|
IndentPPDirectives: None
|
2023-09-12 18:07:15 +08:00
|
|
|
IndentWidth: '4'
|
|
|
|
Language: Cpp
|
|
|
|
MaxEmptyLinesToKeep: '1'
|
2023-09-12 12:02:58 +08:00
|
|
|
NamespaceIndentation: None
|
|
|
|
PointerAlignment: Left
|
2023-09-12 18:07:15 +08:00
|
|
|
SortIncludes: 'true'
|
|
|
|
SortUsingDeclarations: 'true'
|
|
|
|
SpaceAfterCStyleCast: 'false'
|
|
|
|
SpaceAfterLogicalNot: 'false'
|
|
|
|
SpaceAfterTemplateKeyword: 'false'
|
|
|
|
SpaceBeforeAssignmentOperators: 'true'
|
|
|
|
SpaceBeforeCpp11BracedList: 'true'
|
|
|
|
SpaceBeforeCtorInitializerColon: 'true'
|
|
|
|
SpaceBeforeInheritanceColon: 'true'
|
2023-09-12 12:02:58 +08:00
|
|
|
SpaceBeforeParens: ControlStatements
|
2023-09-12 18:07:15 +08:00
|
|
|
SpaceBeforeRangeBasedForLoopColon: 'true'
|
|
|
|
SpaceInEmptyParentheses: 'false'
|
|
|
|
SpacesBeforeTrailingComments: '2'
|
|
|
|
SpacesInAngles: 'false'
|
|
|
|
SpacesInCStyleCastParentheses: 'false'
|
|
|
|
SpacesInContainerLiterals: 'true'
|
|
|
|
SpacesInParentheses: 'false'
|
|
|
|
SpacesInSquareBrackets: 'false'
|
|
|
|
Standard: Cpp11
|
|
|
|
TabWidth: '4'
|
2023-09-12 12:02:58 +08:00
|
|
|
UseTab: Never
|
|
|
|
```
|
2023-09-12 14:44:33 +08:00
|
|
|
|
|
|
|
## 外部参考资料
|
|
|
|
|
|
|
|
1. [Clang 18.0.0git documentation](https://clang.llvm.org/docs/ClangFormatStyleOptions.html)
|
2023-09-12 18:07:15 +08:00
|
|
|
2. [](https://zed0.co.uk/clang-format-configurator/)
|