Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Learn how to change the default tab and indentation behavior for the Code Editor in Visual Studio by using the text editor configuration options.
Access options for indents and tabs
In Visual Studio, open the Tools > Options pane, and expand the All Settings > Languages > Defaults > Tabs section.
Caution
Changes made here apply to all development languages. Resetting options in this dialog overrides individual language settings. To configure options for a specific language, select its subfolder under All Settings > Languages > Language (such as C# or Visual Basic) > Tabs.
In Visual Studio, open the Tools > Options dialog, and expand the Text Editor > All Languages > Tabs section.
Caution
Changes made here apply to all development languages. Resetting options in this dialog overrides 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 receive a reminder about the conflict.
Configure indenting options
For the Indenting option, choose one of the following indenting styles:
- None: New lines aren't 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 { } might be indented an extra tab stop.
Configure tab options
Configure the following tab 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.
Tab character: Select the type of tab character to apply:
- Insert spaces: Indent operations insert only space characters.
- Keep tabs: Indent operations insert as many tab characters as possible; spaces fill any remainder.
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 might override your custom tab settings. To disable adaptive formatting, go to the All Settings > Text Editor > Advanced section in the Tools > Options pane. Toggle the Adaptive formatting option. You can also use an .editorconfig file to manage indent styles.
Tip
Adaptive formatting might override your custom tab settings. To disable adaptive formatting, go to the Text Editor > Advanced section in the Tools > Options dialog. Toggle the Use adaptive formatting option. You can also use an .editorconfig file to manage indent styles.