Skip to main content
A newer version of this page is available. .

Document Formatting (C#)

Document Formatting allows you to enforce code formatting aspects unavailable in the Visual Studio's Code Formatting feature.

Run Format Document Action

You can run the Format Document action in one of the following ways:

  • Check Apply in Action and Apply on Save for the "Format document" rule on the Editor | C# | Code Cleanup options page and run a Code Cleanup.

    Formatting_Spaces

  • Enable "Format block on }" and/or "Format statement on ;" options on the Editor | C# | Formatting | General options page to maintain formatting as you type.

    Formatting_Spaces

  • Press Ctrl+. or Ctrl+~ to invoke the Code Actions Menu, select "Format Document" and press Enter.

    Formatting_Spaces

  • Create a new shortcut and bind it to the "FormatDocument" command. Formatting_Shortcut

    The following screencast shows how the Ctrl+G shortcut initiates a Document Formatting action: Formatting_Shortcut

Document Formatting Options

Use the preview box at the bottom of the Editor | C# | Formatting options page to see an example of every item.

Formatting_Spaces