Question:
I installed a Microsoft plugin for arduino development in Visual studio code, but when auto-formatting, when you press ctrl+shift+i
editor wraps the curly brace to the next line, for example, when declaring a procedure and not only:
void setup
{
...
}
but I would like this:
void setup {
...
}
How to fix?
Answer:
Install clang-format.
Install the VSCode Clang-format plugin.
In settings.json specify the setting
...
"clang-format.executable": "clang-format", // или путь до clang-format
...
In the root folder of the project, create a .clang-format file for example with the content:
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true/false
AfterFunction: true
AfterNamespace: true/false
AfterObjCDeclaration: true/false
AfterStruct: true/false
AfterUnion: true/false
BeforeCatch: true/false
BeforeElse: true/false
IndentBraces: true/false
BreakBeforeBraces: Custom
Ready!
Clang-format documentation: https://clang.llvm.org/docs/ClangFormat.html
.Clang-format config creation interactively: https://clangformat.com/