How can I modify the code formatting for C++ in Visual Studio Code?

After some experiments, the simple solution is to add this line in the User Settings (settings.json):

"C_Cpp.clang_format_fallbackStyle": "{ PointerAlignment: Left}"

However, this settings allow me to keep my previous settings without breaking my function line:

"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: WebKit, ColumnLimit: 120, PointerAlignment: Left}"

Using "BasedOnStyle: Visual Studio" such as this line:

"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Visual Studio, ColumnLimit: 120, PointerAlignment: Left}"

doesn't work. It is may be a bug. I used Visual Studio Code version 1.26.1.

Additionally, a .clangformat outside the workspace folder will still be applied. So, if this file is corrupt the auto-format will not work.


I use clang-format, which integrates quite well and is very configurable. See https://code.visualstudio.com/docs/cpp/cpp-ide#_code-formatting