I am using clang-format based code formatting in Visual Studio Code. I was using this config for the formatting:
"C_Cpp.clang_format_style": "{ BasedOnStyle: Google, BreakBeforeBraces: Stroustrup, IndentWidth: 4, AccessModifierOffset: -4, ColumnLimit: 100}",
As I was unable to force the K&R braces style, I thought about switching to BasedOnStyle: Visual Studio, as VS uses that kind of braces and I saw the Visual Studio option somewhere.
The problem is, now when I format the code I get the following error:
Formatting failed:
"c:\Users\dabljues\.vscode\extensions\ms-vscode.cpptools-0.20.1/bin/../LLVM/bin/clang-format.exe" -style="{ BasedOnStyle: Visual Studio, BreakBeforeBraces: Stroustrup, IndentWidth: 4, AccessModifierOffset: -4, ColumnLimit: 100}" -fallback-style="LLVM" -sort-includes=1 -assume-filename="c:\Users\dabljues\Dropbox\projects\cpp\test\template\src\main.cpp"
YAML:1:3: error: Unknown value for BasedOnStyle: Visual Studio
{ BasedOnStyle: Visual Studio, BreakBeforeBraces: Stroustrup, IndentWidth: 4, AccessModifierOffset: -4, ColumnLimit: 100}
^
Error parsing -style: invalid argument
Of course, now I looked at the official docs and they say nothing about this option. The problem still persists, as I want this:
if ()
{
}
instead of this:
if () {
}
I thought the Stroustrup braces style was like this, but it's not. Not even with functions. So my question would be: Do you guys know how to force clang-format to use the first braces style I mentioned?