Skip to content

Instantly share code, notes, and snippets.

@sergev
Last active August 5, 2021 06:38
Show Gist options
  • Save sergev/b2d1fc5edf7c240bcbd87d3e43ea916f to your computer and use it in GitHub Desktop.
Save sergev/b2d1fc5edf7c240bcbd87d3e43ea916f to your computer and use it in GitHub Desktop.
My preferred C++ code formatting style
---
BasedOnStyle: Google
#
# Indent by four columns.
#
IndentWidth: 4
#
# Limit source width by 100 columns.
#
ColumnLimit: 100
#
# The brace breaking style:
# attach braces to surrounding context, but break before functions.
#
BreakBeforeBraces: WebKit
#
# For case labels, use the same indentation level as for the switch statement.
#
IndentCaseLabels: false
#
# For access modifiers (like public:),
# use the same indentation level as the class statement.
#
AccessModifierOffset: -4
#
# Align pointers to the right, like: int *a;
#
DerivePointerAlignment: false
PointerAlignment: Right
#
# Short functions, loops or ifs should be split into multiple lines.
#
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
#
# Break inheritance list and constructor initializers before colon.
#
BreakInheritanceList: BeforeColon
BreakConstructorInitializers: BeforeColon
ConstructorInitializerAllOnOneLineOrOnePerLine: false
#
# Align trailing comments.
#
AlignTrailingComments: true
SpacesBeforeTrailingComments: 1
#
# Put function definition’s parameters either all on the same line or one line each.
#
BinPackParameters: false
AllowAllParametersOfDeclarationOnNextLine: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment