Skip to main content

Command Palette

Search for a command to run...

c# Visual Studio turn off auto formatting for code area

Published
1 min read
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
}

More from this blog

Yet another developer journey ...

19 posts