visual-studio-codeclang-format

clang-format file not working in Visual Studio code


I have put a .clang-format file in my workspace. But that formatting is not applied on my code. I have checked the settings and they are set to None for fallback-style and file for clang_format_style.

The good news is that the fallback Style doesn't work anymore. Which means when I try to Format the Document or Selection nothing happens.

This is what I did to make my custom formatting:

visualstudio.com: Edit C++ in Visual Studio Code

But there is something missing and the formatting is no happening. This is what my .clang-format in my workspace looks like:

{ 
UseTab: 14, 
IndentWidth: 4,
 BreakBeforeBraces: BS_Attach,
 AllowShortIfStatementsOnASingleLine: false,
 IndentCaseLabels: false,
 ColumnLimit: 0 
}

Solution

  • If the formatting differences are small, VS Code may be running a different version of clang-format than what you expect. By default, vscode-cpptools uses a bundled version of clang-format. If you'd like to use a different version, you'll need to set C_Cpp.clang_format_path in your settings.