A screenshot of the visual studio 2019 format on save option

Clang-format format only on save for Visual Studio

Temps de lecture: < 1 minute

It took me some times to understand how to format only on save on visual studio. Here are the steps for posterity:


  1. Install extension « format on save »
  2. Disable all the automatic formating options (« Automatically format X when I type Y »)
  3. Set « ClangFormat execution » to « Run ClangFormat only for manually invoked formatting commands »

The 3rd one is the most obscure. Without it, formatting will continue to happen, randomly making your cursor jump in the middle of a sentence because formatting occured and the file changed under your feet. 😉

Laisser un commentaire

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *