Skip to content
Amal Hashim
All posts
Snippet

Visual Studio Code Formatting

Control how Visual Studio formats your C# code and format a whole document with one shortcut.

1 min read#C##Visual Studio

Well written code has proper formatting and indentation, which makes it easier to read. Visual Studio formats code as you type, and you can customise the rules.

  1. Open the Options dialog from Tools -> Options.
  2. Select Text Editor -> C# -> Formatting.
  3. Adjust the settings to match your team's style.

Visual Studio 2008 Options dialog showing the C# formatting settings

To format the current document, use Edit -> Advanced -> Format Document. The keyboard shortcut is Ctrl + E, D.