I never knew we put in object model support for the Import / Export Settings feature. When I was testing the feature, I remember being told there wasn’t time in the schedule to do it. Obviously priorities changed after I moved onto the next feature area, and I never got the memo. I so could  have used this tip for the entire past year or two or three…

Let’s say you want Visual Studio to have different window layout at the snap of your fingers. Or even better, you want to toggle VS in and out of a “presentation mode.” (This doesn’t have to be just for Window Layouts and Fonts and Colors. This could work for any settings captured by the Import / Export Settings wizard.)

VS Main Menu showing 2 icons for vssettings files

I’ve mapped the Coffee Mug Icon to the General Development Settings* and the Video Camera Icon to my settings whenever I give presentations. Now I can quickly toggle between presentation mode and work mode.

here’s how you can do it:

  1. Go to Tools – Macros – Macros IDE, and in the Project Explorer, create a Module file (or just use MyMacros-Module1 if it’s not being used.)
  2. Paste in the following code and of course tweak your file path and file names.
    Public Sub ImportPresentationMode()
        DTE.ExecuteCommand("Tools.ImportandExportSettings", 
                 "-import:""C:\Users\saraf\Documents\Visual Studio 2008\
                 Settings\VisualStudioTipsAndTricksDemo.vssettings""")
    End Sub

    Public Sub ImportGenericEnvironment()
        DTE.ExecuteCommand("Tools.ImportandExportSettings", 
                 "-import:""C:\Program Files\Microsoft Visual Studio 9.0\
                 Common7\IDE\Profiles\General.vssettings""")
    End Sub
  1. With the macros create, to go Tools – Customize, and on the Commands tab, select Macros in the Categories section to find the macros you just created in Step 2.

Tools - Customize - Commands menu

  1. And simply drag and drop those macro commands to the toolbar of your choice, or create your own VS Settings toolbar (on the Toolbar page of this dialog.)

After making this customization, I recommend restarting VS to write out any necessary info about the command bars before doing exporting your new customizations.

*Note: I use General Development Settings because it is my baseline default. However if you want to do this toggle back and forth like i’m doing, you will need to add these toolbar button customizations to your General.settings file. Otherwise, you’ll do the toggle, and you’ll import the VS Installed general settings, and the buttons will disappear. Yes, I obviously did this to myself the first time.

Thanks to James’s whitepaper on VS 2005 IDE Tips and Tricks that made me aware of this.

http://msdn.microsoft.com/en-us/library/bb245788(VS.80).aspx

Technorati Tags: VS2005Tip,VS2008Tip