identitycrisisuk
identitycrisisuk

Reputation: 936

Deleting tabs when using tabs as spaces

I know that the general tabs vs spaces thing is as old as the hills and mostly comes down to personal preference/sticking to the style of your team, I just wanted to ask a practical question about using spaces in Visual Studio. There are certain things about tabs that bug me and I wouldn't mind changing to spaces while we're a small team. It would be no different for writing the code in the first place but would mean you'd have to delete/backspace 4 times where I'd previously press it once.

Is there any easy way of deleting tab sized amounts of spaces easily (other than dragging with the mouse etc.) or if you've gone through the changeover yourself is it something that eventually doesn't bother you at all?

Upvotes: 49

Views: 107564

Answers (5)

Justicle
Justicle

Reputation: 15133

In Visual Studio 2015

  1. Open file.
  2. Select all lines you wish to modify (or CTRL+A for entire file).
  3. Choose Edit->Advanced->"Untabify selected lines"

Upvotes: 1

jedmao
jedmao

Reputation: 10502

I've been plagued by the same issue for years. Finally, I did something about it. Let me officially announce version 0.1.0 of the TabSanity Visual Studio extension for VS 2012.

It doesn't just stop at backspaces. It handles the delete key as well as arrow key navigation. Mouse interactions planned for near-future development.

There are some minor bugs I still need to resolve, but the groundwork is laid and I'm making steady progress. It's an open source project, so feel free to contribute on GitHub.

Upvotes: 6

mcandre
mcandre

Reputation: 24602

I don't think there is an easy answer to this problem. I use Xcode and Visual Studio, and both have really annoying indentation. Maybe there's an option to disable autoindentation altogether.

Upvotes: 0

Forgotten Semicolon
Forgotten Semicolon

Reputation: 14100

In Visual Studio, use Shift-Tab. This will go back one tab-stop, even when using soft tabs.

Upvotes: 112

Task
Task

Reputation: 3686

Yes, there's a very easy way.
You set your Visual Studio options (Tools/Options/Text Editor) to use spaces instead of tabs and then you open a source file and Ctrl-E,D (Edit/Advanced/Format Document) and it will convert them all for you!

Yay for automation!

Upvotes: -1

Related Questions