Skip to content

Instantly share code, notes, and snippets.

@guilhermgonzaga
Last active March 20, 2022 15:00
Show Gist options
  • Save guilhermgonzaga/50feab05b9a8d3a105ef18019fe158cc to your computer and use it in GitHub Desktop.
Save guilhermgonzaga/50feab05b9a8d3a105ef18019fe158cc to your computer and use it in GitHub Desktop.
Simple, reasonable, and flexible Clang-Format configuration for C/C++ code. To be extended...
BasedOnStyle: Chromium
---
Language: Cpp
AccessModifierOffset: -2 # Negative of TabWidth
AlignConsecutiveAssignments: false
AlignConsecutiveBitFields: true
AlignConsecutiveDeclarations: false
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
BinPackArguments: true
BinPackParameters: true
BreakBeforeBraces: Custom # Like Stroustrup, but does not break after function
BraceWrapping:
AfterFunction: false
BeforeCatch: true
BeforeElse: true
ColumnLimit: 85
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ContinuationIndentWidth: 2 # Same as TabWidth
DerivePointerAlignment: true
IndentCaseLabels: false
IndentGotoLabels: false
IndentWidth: 2 # Same as TabWidth
MaxEmptyLinesToKeep: 2
PenaltyBreakComment: 35
PenaltyExcessCharacter: 5
PointerAlignment: Right
ReferenceAlignment: Left
ReflowComments: true
SortIncludes: Never
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: false
TabWidth: 2 # Update AccessModifierOffset, ContinuationIndentWidth, IndentWidth
UseTab: AlignWithSpaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment