#966 – Visual Studio Code Editor Helps with Indenting

You’ll typically use a consistent indent level in your source code to assist with readability.  Visual Studio helps by automatically indenting your code as you enter it.

For example, if you enter an if statement and then press Enter to move to the next line, Visual Studio automatically indents the then portion of the if statement.

966-001

You can change the indent level by:

  • Selecting Tools | Options
  • Navigating to Text Editor | C# | Tabs
  • Changing the value in the Indent size field  (default is 4)

966-002

Note that the default is to insert a series of spaces when the Tab key is pressed.

You can easily re-format a document to match the requested indent level.  For example, assume that we start with some non-indented code:

966-003

You can indent the entire document by selecting Edit Advanced Format Document.  The document will be re-formatted using the current indent level.

966-004

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a comment