Last active
April 14, 2023 12:48
-
-
Save trungnt13/f13394a3dba2b9a315efeb65b5495e90 to your computer and use it in GitHub Desktop.
[CheatSheet] Clang Format
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Refer to the following link for the explanation of each params: | |
# http://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html | |
Language: Cpp | |
# BasedOnStyle: Google | |
AccessModifierOffset: -1 | |
AlignAfterOpenBracket: Align | |
AlignConsecutiveAssignments: true | |
AlignConsecutiveBitFields: true | |
AlignConsecutiveDeclarations: false | |
AlignConsecutiveMacros: true | |
AlignEscapedNewlines: Left | |
AlignOperands: true | |
AlignTrailingComments: true | |
AllowAllArgumentsOnNextLine: true | |
AllowAllConstructorInitializersOnNextLine: true | |
AllowAllParametersOfDeclarationOnNextLine: true | |
AllowShortBlocksOnASingleLine: true | |
AllowShortCaseLabelsOnASingleLine: true | |
AllowShortEnumsOnASingleLine: true | |
AllowShortFunctionsOnASingleLine: All | |
AllowShortIfStatementsOnASingleLine: true | |
AllowShortLambdasOnASingleLine: true | |
AllowShortLoopsOnASingleLine: false | |
# This is deprecated | |
AlwaysBreakAfterDefinitionReturnType: None | |
AlwaysBreakAfterReturnType: None | |
AlwaysBreakBeforeMultilineStrings: true | |
AlwaysBreakTemplateDeclarations: Yes | |
BinPackArguments: false | |
BinPackParameters: false | |
BraceWrapping: | |
AfterClass: false | |
AfterControlStatement: false | |
AfterEnum: false | |
AfterFunction: false | |
AfterNamespace: false | |
AfterObjCDeclaration: false | |
AfterStruct: false | |
AfterUnion: false | |
AfterExternBlock: false | |
BeforeCatch: false | |
BeforeElse: false | |
IndentBraces: false | |
# disabling the below splits, else, they'll just add to the vertical length of source files! | |
SplitEmptyFunction: false | |
SplitEmptyRecord: false | |
SplitEmptyNamespace: false | |
BreakAfterJavaFieldAnnotations: false | |
BreakBeforeBinaryOperators: None | |
BreakBeforeBraces: WebKit | |
BreakBeforeInheritanceComma: false | |
BreakBeforeTernaryOperators: true | |
BreakConstructorInitializersBeforeComma: false | |
BreakConstructorInitializers: BeforeColon | |
BreakInheritanceList: BeforeColon | |
BreakStringLiterals: true | |
ColumnLimit: 100 | |
CommentPragmas: "^ IWYU pragma:" | |
CompactNamespaces: false | |
ConstructorInitializerAllOnOneLineOrOnePerLine: true | |
# Kept the below 2 to be the same as `IndentWidth` to keep everything uniform | |
ConstructorInitializerIndentWidth: 2 | |
ContinuationIndentWidth: 2 | |
Cpp11BracedListStyle: true | |
DerivePointerAlignment: false | |
DisableFormat: false | |
ExperimentalAutoDetectBinPacking: false | |
FixNamespaceComments: true | |
ForEachMacros: | |
- foreach | |
- Q_FOREACH | |
- BOOST_FOREACH | |
IncludeBlocks: Preserve | |
IncludeIsMainRegex: "([-_](test|unittest))?$" | |
IndentCaseLabels: true | |
IndentPPDirectives: None | |
IndentWidth: 2 | |
IndentWrappedFunctionNames: false | |
JavaScriptQuotes: Leave | |
JavaScriptWrapImports: true | |
KeepEmptyLinesAtTheStartOfBlocks: false | |
MacroBlockBegin: "" | |
MacroBlockEnd: "" | |
MaxEmptyLinesToKeep: 1 | |
NamespaceIndentation: None | |
ObjCBinPackProtocolList: Never | |
ObjCBlockIndentWidth: 2 | |
ObjCSpaceAfterProperty: false | |
ObjCSpaceBeforeProtocolList: true | |
PenaltyBreakAssignment: 2 | |
PenaltyBreakBeforeFirstCallParameter: 1 | |
PenaltyBreakComment: 300 | |
PenaltyBreakFirstLessLess: 120 | |
PenaltyBreakString: 1000 | |
PenaltyBreakTemplateDeclaration: 10 | |
PenaltyExcessCharacter: 1000000 | |
PenaltyReturnTypeOnItsOwnLine: 200 | |
PointerAlignment: Left | |
RawStringFormats: | |
- Language: Cpp | |
Delimiters: | |
- cc | |
- CC | |
- cpp | |
- Cpp | |
- CPP | |
- "c++" | |
- "C++" | |
CanonicalDelimiter: "" | |
- Language: TextProto | |
Delimiters: | |
- pb | |
- PB | |
- proto | |
- PROTO | |
EnclosingFunctions: | |
- EqualsProto | |
- EquivToProto | |
- PARSE_PARTIAL_TEXT_PROTO | |
- PARSE_TEST_PROTO | |
- PARSE_TEXT_PROTO | |
- ParseTextOrDie | |
- ParseTextProtoOrDie | |
CanonicalDelimiter: "" | |
BasedOnStyle: google | |
# Enabling comment reflow causes doxygen comments to be messed up in their formats! | |
ReflowComments: true | |
SortIncludes: true | |
SortUsingDeclarations: true | |
SpaceAfterCStyleCast: false | |
SpaceAfterTemplateKeyword: true | |
SpaceBeforeAssignmentOperators: true | |
SpaceBeforeCpp11BracedList: false | |
SpaceBeforeCtorInitializerColon: true | |
SpaceBeforeInheritanceColon: true | |
SpaceBeforeParens: ControlStatements | |
SpaceBeforeRangeBasedForLoopColon: true | |
SpaceBeforeSquareBrackets: false | |
SpaceInEmptyBlock: false | |
SpaceInEmptyParentheses: false | |
SpacesBeforeTrailingComments: 2 | |
SpacesInAngles: false | |
SpacesInConditionalStatement: false | |
SpacesInContainerLiterals: true | |
SpacesInCStyleCastParentheses: false | |
SpacesInParentheses: false | |
SpacesInSquareBrackets: false | |
Standard: c++17 | |
StatementMacros: | |
- Q_UNUSED | |
- QT_REQUIRE_VERSION | |
# Be consistent with indent-width, even for people who use tab for indentation! | |
TabWidth: 2 | |
UseTab: Never |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment