How to apply format when saving in Visual Studio 2022?

Viewed 845

I have placed a .clang-format file in my project and can apply the formatting with Ctrl+K, Ctrl+D. I have also configured and enabled "Run Code Cleanup profile on Save" under Options -> Text Editor -> Code Cleanup. But when I save a file, the formatting is not applied.

Is there something I'm missing?

Thank you in advance!

Edit: Since it does not seem to be possible for C++ (as of June 2022), I will be using the extension Format on Save for VS2022 for now, which has a bit more functionality compared to Sedenion's suggestion.

2 Answers

Unfortunately, Code Cleanup only applies to C# and VB.Net, and not to C++ code.

From MS documentation

For C# code, you can also configure Visual Studio to apply these code style preferences using the Code Cleanup

Related