My clang-format produces code like this:
enum class SomeEnum{ VAL1, VAL2, VAL3 };
class SomeClass {
public:
void someMethod();
private:
int m_field;
};
void someFunc()
{
// ...
}
But I want it to be like this:
enum class SomeEnum {
VAL1,
VAL2,
VAL3
};
class SomeClass {
public:
void someMethod();
private:
int m_field;
};
void someFunc() {
// ...
}
So I need enums to not be reduced to one line like this, for class methods and fields to have an additional level of indentation after access specifiers, and for the opening curly brace of my functions to be one space after ')' and not in another line
Here is my .clang-format file
AccessModifierOffset: '0'
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: 'true'
AlignEscapedNewlines: Left
AlignTrailingComments: 'true'
AllowAllArgumentsOnNextLine: 'false'
AllowAllConstructorInitializersOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BreakBeforeBraces: Stroustrup
ColumnLimit: '120'
CompactNamespaces: 'false'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'true'
FixNamespaceComments: 'true'
IndentCaseLabels: 'true'
IndentWidth: '4'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
Language: Cpp
MaxEmptyLinesToKeep: '2'
NamespaceIndentation: All
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'false'
SpaceAfterLogicalNot: 'false'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCtorInitializerColon: 'true'
SpaceBeforeInheritanceColon: 'true'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInSquareBrackets: 'false'
TabWidth: '4'
UseTab: ForContinuationAndIndentation
CodePudding user response:
AllowShortEnumsOnASingleLine: false # is available since clang-format 12.
IndentAccessModifiers: true # is available since clang-format 13.
BraceWrapping:
AfterFunction: false
