Yet another developer journey ...

Yet another developer journey ...

c# Visual Studio turn off auto formatting for code area

Photo by Sigmund on Unsplash

c# Visual Studio turn off auto formatting for code area

Dominik Schischma's photo
Dominik Schischma
·Jun 27, 2022·

1 min read

Sometimes you do not want to have auto formatting enabled for specific code areas. Mostly I am using that for short switch statements, for a better code readability.

Specific code areas can be excluded by using the formatter directive:

switch (arg.ToLower())
{
  // @formatter:off
  case "create": action = CliAction.Create; break;
  case "list": action = CliAction.List; break;
  // @formatter:on
}
 
Share this