Visual Studio replace tab with 4 spaces?

Visual Studio

Visual Studio Problem Overview


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?

Visual Studio Solutions


Solution 1 - Visual Studio

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.

Solution 2 - Visual Studio

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.

See MSDN blog

Solution 3 - Visual Studio

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.

Solution 4 - Visual Studio

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

Solution 5 - Visual Studio

If you don't see the formatting option, you can do Tools->Import and Export settings to import the missing one.

Solution 6 - Visual Studio

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNickolay KondratyevView Question on Stackoverflow
Solution 1 - Visual StudioReed CopseyView Answer on Stackoverflow
Solution 2 - Visual StudioJeroen VLView Answer on Stackoverflow
Solution 3 - Visual StudioBryan NeubergerView Answer on Stackoverflow
Solution 4 - Visual StudioVaman AcharyaView Answer on Stackoverflow
Solution 5 - Visual Studiouser5162573View Answer on Stackoverflow
Solution 6 - Visual StudioVimNingView Answer on Stackoverflow