c++ubuntuvisual-studio-codelint

Visual Studio Code formatting for "{ }"


I'm on Ubuntu. C++ in Visual Studio Code automatically lints like

if (condition == true)
{
  DoStuff();
}

Instead I want to do :

if (condition == true) {
  DoStuff();
}

How do I do that?

I've already installed the C/C++ extension from the marketplace.


Solution

  • base on @Chris Drew's answer

    1. Go Preferences -> Settings
    2. Search for C_Cpp.clang_format_fallbackStyle
    3. Change from Visual Studio to { BasedOnStyle: Google, IndentWidth: 4 }

    In user settings.json, that looks like this:

    If you want more:

    More detail:

    English: https://medium.com/@zamhuang/vscode-how-to-customize-c-s-coding-style-in-vscode-ad16d87e93bf

    Taiwan: https://medium.com/@zamhuang/vscode-%E5%A6%82%E4%BD%95%E5%9C%A8-vscode-%E4%B8%8A%E8%87%AA%E5%AE%9A%E7%BE%A9-c-%E7%9A%84-coding-style-c8eb199c57ce