Learn how to change the default tab and indentation behavior for the Code Editor in Visual Studio using the text editor configuration options.
Access options for indents and tabs
- Open Visual Studio.
- On the menu bar, select Tools > Options.
- In the Options dialog, expand the Text Editor node.
- Expand All Languages, then select Tabs.
Caution
Changes made here apply to all development languages. Resetting options in this dialog will override individual language settings. To configure options for a specific language, select its subfolder under Text Editor.
Resolve conflicting settings
If you select different tab or indent settings for individual languages, Visual Studio displays a warning message:
- "The indentation settings for individual text formats conflict with each other," for differing Indenting options.
- "The tab settings for individual text formats conflict with each other," for differing Tab options.
For example, if Smart indenting is set for Visual Basic and Block indenting for Visual C++, you’ll see a reminder about the conflict.
Configure indenting options
In the Indenting section, choose one of the following indenting styles:
- None: New lines are not indented; the cursor starts at the first column.
- Block: New lines are automatically indented to match the previous line.
- Smart: New lines are indented based on code context and IntelliSense conventions. Not available for all languages.
For example, lines between braces { }
may be indented an extra tab stop.
Configure tab options
In the Tabs section, choose the following options.
- Tab size: Sets the number of spaces per tab stop (default: 4).
- Indent size: Sets the number of spaces for each indentation (default: 4). Tabs, spaces, or both are used to fill the size.
- Insert spaces: Indent operations insert only space characters.
- Keep tabs: Indent operations insert as many tab characters as possible; spaces fill any remainder.
Troubleshooting
Tip
Adaptive formatting may override your custom tab settings. To disable adaptive formatting, go to Text Editor > Advanced and toggle Use adaptive formatting. You can also use an .editorconfig file to manage indent styles.