#966 – Visual Studio Code Editor Helps with Indenting
November 4, 2013 Leave a comment
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.
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)
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:
You can indent the entire document by selecting Edit | Advanced | Format Document. The document will be re-formatted using the current indent level.