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 *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax