Visual Studio 2005 and Bad Tabulation

I have a dual screen setup with two 20″ Dell LCD screens. I recently changed my primary screen to be vertically orientated. The benefit here is that I can see a more “global” view of the source file I am currently editing. The irritating thing I stumbled upon was tabulation in Visual Studio.

I changed my tabs to be 2 spaces instead of two (to make up for my primary screen having less horizontal space). The issue that I had was all old source files were stuck with 4 space tabbing.

Here is what I did to fix the issue:
Tools>>options (make sure “Show all settings” is checked)
Navigate to Text Editor>>All Languages>>Tabs

  • In the Tab box, change the tab size to 2 and indent size to 2
  • select “Keep tabs” (this tells visual studio to not change tabs to spaces)

Okay, so now the editor now uses two tabs and I can manually fix code I made before using shift-tab. This doesn’t solve my issue of having old source files stuck with 4 spaces as one tab.

What I just figured out is when I copy 4-space tabbed code and paste it back into the editor, it formats the tabs to the new specification.

NOTE: I do not suggest you do the below method with FORM source files or any auto generated code. This will probably confuse the IDE…

So I just did a ctrl-a (select all), ctrl-x (cut), ctrl-v (paste) on each source file and the tabbing is now fixed!