From ab7cc1e47140bae6b7ae1bc8d34d07746dd0d24d Mon Sep 17 00:00:00 2001 From: "rick.chan" Date: Tue, 12 Sep 2023 18:07:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=A3=8E=E6=A0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rick.chan --- .../Clang/Clang_Format_自定义风格.md | 170 +++++++++--------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/Software/Applications/Clang/Clang_Format_自定义风格.md b/Software/Applications/Clang/Clang_Format_自定义风格.md index 6bb482c..ac2e3ae 100644 --- a/Software/Applications/Clang/Clang_Format_自定义风格.md +++ b/Software/Applications/Clang/Clang_Format_自定义风格.md @@ -1,107 +1,107 @@ # Clang Format 自定义风格 ```js -Language: Cpp BasedOnStyle: Google -AccessModifierOffset: -1 +AccessModifierOffset: '-1' AlignAfterOpenBracket: Align -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 -# clang-format 17 -# AlignConsecutiveShortCaseStatements: -# Enabled: true -# AcrossEmptyLines: false -# AcrossComments: false -# AlignCaseColons: false AlignEscapedNewlines: Left -AlignOperands: AlignAfterOperator +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 -AllowAllArgumentsOnNextLine: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: Empty -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: Never # To avoid conflict, set this "Never" and each "if statement" should include brace when coding -AllowShortLambdasOnASingleLine: Inline -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterReturnType: None -AlwaysBreakTemplateDeclarations: Yes -AlignArrayOfStructures: Right -BinPackArguments: true -BinPackParameters: false -BitFieldColonSpacing: Before -BreakBeforeBraces: Allman -BreakBeforeBinaryOperators: NonAssignment -BreakBeforeTernaryOperators: true -BreakArrays: false -BreakBeforeInlineASMColon: OnlyMultiline +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 -CompactNamespaces: false -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false # Make sure the * or & align on the left -EmptyLineBeforeAccessModifier: Always -FixNamespaceComments: true +BreakStringLiterals: 'true' +ColumnLimit: '80' +ContinuationIndentWidth: '4' IncludeBlocks: Regroup -IndentCaseLabels: false +IndentCaseLabels: 'false' IndentPPDirectives: None -IndentWidth: 4 -IndentAccessModifiers: false -IndentCaseBlocks: false -IndentExternBlock: NoIndent -IndentGotoLabels: false -IndentRequiresClause: false -IndentWrappedFunctionNames: false -InsertBraces: true -KeepEmptyLinesAtTheStartOfBlocks: true -MaxEmptyLinesToKeep: 1 +IndentWidth: '4' +Language: Cpp +MaxEmptyLinesToKeep: '1' NamespaceIndentation: None -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true PointerAlignment: Left -ReflowComments: false -# SeparateDefinitionBlocks: Always # Only support since clang-format 14 -SpaceAfterCStyleCast: false -SpaceAfterLogicalNot: false -SpaceAfterTemplateKeyword: true -SpaceBeforeAssignmentOperators: true -SpaceBeforeCpp11BracedList: false -SpaceBeforeCtorInitializerColon: true -SpaceBeforeInheritanceColon: true +SortIncludes: 'true' +SortUsingDeclarations: 'true' +SpaceAfterCStyleCast: 'false' +SpaceAfterLogicalNot: 'false' +SpaceAfterTemplateKeyword: 'false' +SpaceBeforeAssignmentOperators: 'true' +SpaceBeforeCpp11BracedList: 'true' +SpaceBeforeCtorInitializerColon: 'true' +SpaceBeforeInheritanceColon: 'true' SpaceBeforeParens: ControlStatements -SpaceBeforeRangeBasedForLoopColon: true -SpaceBeforeSquareBrackets: false -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 2 -SpacesInAngles: false -SpacesInCStyleCastParentheses: false -SpacesInContainerLiterals: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: c++11 -TabWidth: 4 +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](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) +2. [](https://zed0.co.uk/clang-format-configurator/)