Nickolay Kondratyev
Nickolay Kondratyev

Reputation: 5211

Visual Studio replace tab with 4 spaces?

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?

Upvotes: 310

Views: 297442

Answers (10)

Vaman Acharya
Vaman Acharya

Reputation: 325

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

Upvotes: 20

Leonor
Leonor

Reputation: 1

In Mac: Code -> Preferences -> Settings, buscar "indentation" enter image description here y desmarcar la casilla Insert spaces when pressing

Upvotes: 0

Ynjxsjmh
Ynjxsjmh

Reputation: 29982

In my Microsoft Visiual Studio Enterprise 2019 Version 16.11.20, there is a file status line at the right bottom corner of the file window, it looks like:

Ln: 15  Ch: 3   TABS    CRLF

Besides changing Tabs option under Tools -> Options -> Text Editor to Insert spaces. I also need to mannually change the TABS in the file status line to Spaces by clicking on it. Then it looks like

Ln: 15  Ch: 3   SPC     CRLF

Instead of clicking the file status line, you can also change this in navigation bar Edit -> Advanced -> Set Indentation -> Spaces.

Upvotes: 2

Alexander
Alexander

Reputation: 71

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

Upvotes: 2

godGivesMeLanguages
godGivesMeLanguages

Reputation: 63

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

Upvotes: 0

NeoZoom.lua
NeoZoom.lua

Reputation: 2891

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

Upvotes: 7

Bryan Neuberger
Bryan Neuberger

Reputation: 208

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.

Upvotes: 9

Reed Copsey
Reed Copsey

Reputation: 564323

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.

Upvotes: 435

Jeroen VL
Jeroen VL

Reputation: 351

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

Upvotes: 14

user5162573
user5162573

Reputation: 61

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

Upvotes: 6

Related Questions