Posted on August 2, 2023, 9:52 am By agathezol
When using clang-format as the code formatter in vscode you can create a ‘.clang-format’ file in the root of your project directory. This allows precise control over how code is formatted. Every program I know has specific ways they want their code formatted. Here is my clang-format file for my own reference:
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
ColumnLimit: 0
SpaceAfterCStyleCast: false
UseTab: Never
AllowShortIfStatementsOnASingleLine: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterCaseLabel: true
AfterControlStatement: false
AfterFunction: true
AfterStruct: false
AfterUnion: false
BeforeElse: false
BeforeWhile: false
AlignAfterOpenBracket: AlwaysBreak
InsertBraces: true
IndentCaseLabels: true
Categories: General, Linux