How to get clang-format working in Visual Studio

13,039

Strangely enough, this started to work without any extra changes after a couple of days.

Share:
13,039
JVApen
Author by

JVApen

C++ programmer, Linux user (@home) and LLVM enthusiast. Special interests in: Upcoming C++ standards multi-threading code simplicity compiler optimizations What every C++ programmer should know: Communities should improve C shouldn't be taught to learn C++ Basic compiler optimizations Awesome tools to improve your workflow Posts I'm proud on: Named arguments based on strong typing When not to allocate memory No need for std::enable_if How do lambdas work Iterate over Enumerations Value semantics and rule of 5 explained to Java programmer

Updated on June 07, 2022

Comments

  • JVApen
    JVApen almost 2 years

    Visual Studio has native integration for clang-format since 15.7 prev1.

    I'm using 15.9.9 and nicely see the configuration in the options. Visual Studio Configuration C++ Formatting

    From my understanding, as 'Google' is selected in the formatting style, it should use either my .clang-format file which is in the root of my checkout or fallback to the hard-coded configuration with name 'Google'.

    However, if I format my file: Ctrl+K, Ctrl+D, my file gets formatted using Whitesmiths; which is the brace configuration of my Visual Studio formatting.

    Did I forget to configure something that allows me to use clang-format or is something horribly going wrong? If it is the last one, I appreciate some debugging tips.