Getting VS.NET to use tabs for some projects and spaces for others

I ran into an issue today where Neil needs to use spaces for most of his coding (apparently print designers still haven’t caught on to what exactly a tab is) but for consistency he needs to use tabs on a shared project. Reconfiguring your VS every time you want to do some coding kinda sucks, so Paul and I went in search of a better solution.

Paul’s first suggestion was that we create another user account, and then have two different VS shortcuts. Shortcut A launches VS.NET under user account A using profile A. Shortcut B launches VS.NET under user account B using profile B. We pretty quickly got scared of this option for a number of reasons:

  • Under Vista you need to run VS.NET with privelige escalation, and if you wanted two VS.NET instances running sdie-by-side under two different escalations jsut sounds scary. It means you’d have total of 4 tokens in play for those two processes alone.
  • Knowing .NET debugging and other assorted “platform sugar” would quite likely curl up and die. Most third party addins just curl up and die in this case as well.
  • If you wanted to reconfigure your IDE you’d have to do every change twice.

My next though was to see if we could specify it as a command switch at all. We couldn’t – but we could reset the IDE settings with the /ResetSettings switch. Better yet, we could supply a .vssettings file to the switch and the IDE would load it up. Our shotcuts now look like this:

devenv.exe /ResetSettings UseRealTabsLikeRealMen.vssettings

devenv.exe /ResetSettings UseCrappyFakeTabsLikeALittleGirl.vssettings

(Note: The names of the settings files are crucial to this solution working.)

The really really cool thing is that .vssettings files don’t need to define every setting – just the ones you actual want to load. By selectively exporting some settings then massaging the XML by hand I created settings files that just defines the tab settings.

Simple!

Everything except your tab settings are shared across the profile like normal. Addins work like normal. No crazy user accounts. If you’re working with a number of different projects and teams this is a nice way of customizing your IDE per project.

Download: http://tatham.oddie.com.au/files/VsTabConfigurationShortcuts.zip