Is there a way to set TAB button to work as 4 spaces in Visual Studio 2010 instead of going to Edit->Advanced->Untabify Selected Lines?
-
23+1 since within the question there is the hint how to *untabify* already existent sources, the accepted answer applies only for *new* sources – Shmil The Cat Oct 07 '14 at 17:33
-
1Would somebody mind editing the "2010" out of the question title? This is applicable to many visual studio versions, and the UI is still the same for this part of the IDE for VS 2010, 2013, and 2015. Also it might help to add something to the question that implies that the OP is looking to set the style of new sources; the trick for editing existing sources is cool though. – jrh Dec 29 '16 at 18:52
-
2Also note that "Tabify" and "Untabify" for existing source code files does not work for tabs inserted in the middle of the line, i.e., `
int – jrh Apr 29 '17 at 19:35x;` would be replaced with ` int x;`, not ` int x;` -
1I am using Visual Studio Community for Mac and instead of untabify, I did Edit>Format>Format Document. – Mahdi Sep 15 '17 at 07:35
8 Answers
You can edit this behavior in:
Tools->Options->Text Editor->All Languages->Tabs
Change Tab to use "Insert Spaces" instead of "Keep Tabs".
Note you can also specify this per language if you wish to have different behavior in a specific language.

- 9,137
- 11
- 75
- 83

- 554,122
- 78
- 1,158
- 1,373
-
17
-
7
-
2
-
3In mine what took me so long to find the setting was the fact that theres a checkbox that hides half the settings. be sure to check show all settings – Andrew Afternoon-Delight Hayde May 01 '15 at 14:42
-
6
-
You can specify number of spaces by entering "Indent size" value. 2 or 4 (default), for example – Vildan Mar 22 '17 at 18:03
-
7
-
1
-
-
Hit Ctr-k,Ctr-D to convert to tabs code that you pasted in from another source. – Chris McCowan Dec 14 '18 at 17:31
-
1@Magallo It looks like "Tab size" tells it how many spaces wide a tab character should be rendered, and "Indent size" is how many space characters to enter when you are using spaces instead of tabs. – hypehuman Jan 10 '19 at 19:54
-
19Well... This is "almost" still the same in VS 2019... if you already done that and seems not to work, go to: Tools > Options, and then Text Editor > Advanced > Uncheck "Use adaptive formatting" as seen [here](https://developercommunity.visualstudio.com/content/problem/847853/visual-studio-20194-c-insert-spaces-instead-of-tab.html) – Gabriel G Jan 28 '20 at 00:35
-
2
-
Couldn't find anything like that in VS2020. Any help would be appreciated. – sequence Nov 12 '20 at 02:56
-
-
For me I had to do the same for `Text Editor > C/C++ (VisualGDB) > Tab > Insert spaces` – Alaa M. Feb 08 '22 at 11:46
First set in the following path Tools->Options->Text Editor->All Languages->Tabs if still didn't work modify as mentioned below Go to Edit->Advanced->Set Indentation ->Spaces

- 187
- 1
- 5
-
2
-
2You can find it in the menu bar at the top of Visual Studio. Or else even you can press Ctrl+Q and type Tools in the search box – Vaman Acharya Nov 27 '20 at 15:43
-
For VS2010 and above (VS2010 needs a plugin). If you have checked/set the options of the tab size in Visual Studio but it still won't work. Then check if you have a .editorconfig file in your project! This will override the Visual Studio settings. Edit the tab-size in that file.
This can happen if you install an Angular application in your project with the Angular-Cli.

- 341
- 5
- 9
None of these answer were working for me on my macbook pro. So what i had to do was go to:
Preferences -> Source Code -> Code Formatting -> C# source code.
From here I could change my style and spacing tabs etc. This is the only project i have where the lead developer has different formatting than i do. It was a pain in the butt that my IDE would format my code different than theirs.

- 198
- 2
- 4
-
4This is correct in Visual Studio for Mac 8.4 (that goes with Unity 2019.2) – gl03 Mar 28 '20 at 16:32
If you don't see the formatting option, you can do Tools->Import and Export settings to import the missing one.

- 61
- 1
- 1
-
can't find it in version 2022. This solved it anyway. Great 2nd method – person27 Apr 20 '22 at 05:30
For Visual Studio 2019 users:
By the comment under accepted answer, link:
Well... This is "almost" still the same in VS 2019... if you already done that and seems not to work, go to: Tools > Options, and then Text Editor > Advanced > Uncheck "Use adaptive formatting" as seen here

- 2,269
- 4
- 30
- 64
-
1The doc below helped me https://learn.microsoft.com/en-us/visualstudio/ide/reference/options-text-editor-all-languages-tabs?view=vs-2019 – João Martins Oct 07 '21 at 23:53
File->Preferences->Settings->'Search Settings'SearchBarAtTheTop='tab size'
Help->About shows:
Visual Studio Code Version: 1.78.2 (user setup)
OS: Windows_NT x64 10.0.19044
Date: 2023-05-10

- 43
- 1
- 6
Tools > Options >Text Editor > Advanced > Uncheck “Use adaptive formatting” https://developercommunity.visualstudio.com/t/tab-will-not-enter-spaces-in-file-with-mixed-inden/1267780

- 51
- 1
- 3