0

Basically the opposite of this question:
How do I set up VSCode to put curly braces on a new line?

I am working with the PlatformIO extension for VSCode and whenever I format the document, I get all my curly braces misplaced on new lines, which looks horrible (coming from Java).

Similar question here, but it is asking about a specific C++ extension.

Big_Chair
  • 2,781
  • 3
  • 31
  • 58

1 Answers1

1

You can add a .clangformat file to your project. For example:

---
BasedOnStyle: Google
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Attach
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AccessModifierOffset: -4
ColumnLimit: 88
...

You can read about the options here: https://clang.llvm.org/docs/ClangFormatStyleOptions.html

Alternatively you can edit your vscode settings fallback style:

{
  "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, TabWidth: 4}"
}
tfeldmann
  • 3,108
  • 1
  • 23
  • 34