place else on new line in Visual Studio Code

477 Views Asked by At

how can I place my else on new line, for example, I want to change

if () {
} else {
}

into

if() {
}
else {
}

I have edit theC_Cpp: Clang_format_fallback Style and entered { BasedOnStyle:Microsoft, IndentWidth: 4, ColumnLimit: 0}

1

There are 1 best solutions below

3
Jonny Soe On

Looks like vscode's formatter uses clang-format by default, so if you didn't change it, we can refer to the clang-format options directly, can you try to append the following key-value (BeforeElse) pair within your braces?

BraceWrapping: [BeforeElse: true]

If that doesn't work, then you should try to use the traditional .clang-format file which vscode also supports.