Skip to content

Instantly share code, notes, and snippets.

@Justasic
Created July 14, 2021 10:59
Show Gist options
  • Save Justasic/15d1282b05179f3626363367c7b27622 to your computer and use it in GitHub Desktop.
Save Justasic/15d1282b05179f3626363367c7b27622 to your computer and use it in GitHub Desktop.
My personal clang-format file for C++ (and maybe other languages)
---
#BasedOnStyle: WebKit
TabWidth: '4'
IndentWidth: '4'
UseTab: 'ForContinuationAndIndentation'
AlignOperands: 'AlignAfterOperator'
AlignAfterOpenBracket: 'Align'
AlignConsecutiveAssignments: 'AcrossEmptyLinesAndComments'
AlignConsecutiveBitFields: 'AcrossEmptyLinesAndComments'
AlignConsecutiveDeclarations: 'AcrossEmptyLinesAndComments'
AlignConsecutiveMacros: 'AcrossEmptyLinesAndComments'
AlignEscapedNewlines: 'Left'
AlignTrailingComments: 'true'
#AlignArrayOfStructures: 'Right'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: 'All'
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AllowShortLambdasOnASingleLine: 'Empty'
AlwaysBreakAfterReturnType: 'None'
AlwaysBreakTemplateDeclarations: 'true'
AlwaysBreakBeforeMultilineStrings: 'false'
BinPackArguments: 'true'
BinPackParameters: 'true'
BreakBeforeBraces: 'Custom'
BraceWrapping:
AfterEnum: 'true'
AfterClass: 'true'
AfterControlStatement: 'true'
AfterStruct: 'true'
AfterFunction: 'true'
AfterNamespace: 'true'
AfterUnion: 'true'
AfterExternBlock: 'true'
BeforeCatch: 'true'
BeforeElse: 'true'
BeforeWhile: 'true'
BeforeLambdaBody: 'true'
SplitEmptyRecord: 'false'
SplitEmptyNamespace: 'false'
SplitEmptyFunction: 'false'
BreakBeforeBinaryOperators: 'true'
BreakBeforeTernaryOperators: 'false'
BreakConstructorInitializersBeforeComma: 'false'
BreakBeforeInheritanceComma: 'false'
BreakStringLiterals: 'true'
ColumnLimit: '180'
CompactNamespaces: 'false'
Cpp11BracedListStyle: 'true'
FixNamespaceComments: 'true'
IncludeBlocks: 'Preserve'
IndentExternBlock: 'AfterExternBlock'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'false'
DerivePointerAlignment: 'false'
EmptyLineBeforeAccessModifier: 'LogicalBlock'
IndentCaseLabels: 'true'
IndentPPDirectives: 'AfterHash'
KeepEmptyLinesAtTheStartOfBlocks: 'true'
MaxEmptyLinesToKeep: '3'
Language: 'Cpp'
NamespaceIndentation: 'All'
PointerAlignment: 'Right'
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeParens: 'ControlStatements'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
SpaceBeforeCaseColon: 'false'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'false'
SpaceBeforeInheritanceColon: 'false'
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceBeforeSquareBrackets: 'false'
SpacesInAngles: 'false'
Standard: 'Auto'
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment