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

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
}