VSCode and Clang-Format

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
    AfterClass: false
    AfterCaseLabel: true
    AfterControlStatement: false
    AfterFunction: true
    AfterStruct: false
    AfterUnion: false
    BeforeElse: false
    BeforeWhile: false
AlignAfterOpenBracket: AlwaysBreak
InsertBraces: true
IndentCaseLabels: true


Agathezol is a gamer, programmer, father, husband, and musician. When he's not writing blog posts nobody reads he generally writes protocol stacks, network code, and core telecommunications software but has dabbled in game design, web programming, mobile device software, and desktop software.

Categories: General, Linux