Visual Studio 2017编辑器换行仅一个Tab,需恢复为两个的问题咨询
Fixing Auto-Indentation to 2 Tabs in Visual Studio 2017
Hey Robert, I’ve run into this exact indentation quirk before in VS2017—let’s get it sorted out quickly. Here are the steps to restore your 2-tab auto-indent when pressing Enter:
1. Check Global Text Editor Settings (Applies to Most Languages)
- Open the Tools menu at the top, then select Options (or press
Ctrl+Q, type "Options", and hit Enter to jump straight there). - In the Options window, expand the Text Editor node, then select General.
- Scroll down to the Indentation section:
- Make sure Auto indent is checked (this enables automatic indentation when you press Enter).
- If you prefer actual Tab characters over spaces, ensure Insert tabs is selected (instead of "Insert spaces").
2. Verify Language-Specific Indentation Settings (Critical!)
VS lets you override indent settings per language, so this is likely where the unexpected change happened:
- Still in the Options window, expand Text Editor again, then select the language you’re working with (e.g.,
C#,C++,HTML, etc.). - Choose the Tabs sub-node under that language.
- Configure these settings:
- Select Keep tabs to ensure actual Tab characters are inserted (not spaces).
- Set Tab size to your preferred width for a single Tab (e.g., 4 characters—this controls how wide each Tab appears, not the number of Tabs inserted).
- Set Indent size to
2—this tells VS to insert 2 Tab characters whenever you press Enter to wrap a line. - Confirm Smart indent is selected under "Indent style" (this ensures indentation matches your code’s context).
3. Reset Settings (If All Else Fails)
If the above steps don’t fix the issue, corrupted settings might be the culprit:
- Go to Tools > Import and Export Settings.
- Select Reset all settings, then follow the prompts to reset to default settings (you can back up your current settings first to preserve other customizations).
- After resetting, revisit the Tabs settings for your language and reconfigure the 2-tab indent as needed.
That should bring back the 2-tab auto-indent you’re used to. Let me know if you hit any snags!
内容的提问来源于stack exchange,提问作者Robert
相关产品推荐
相关产品推荐

