6/26/2008

Workstation Hack: Visual Studio on 2 monitors

Having two monitors is an obvious improvement to any development workstation, but are there tricks for really effectively using all that extra acreage? I learned a great strategy from a co-worker for a two-monitor setup for Microsoft Visual Studio.

Hack Summary
Maximize the editor on one screen, and pull out all the floating windows (Solution Explorer, Error List, etc.) onto the second screen—which is great until you want to look at your database or your wiki or your work-in-progress app while also typing code. (If you're typing in the editor, Visual Studio is in front, which means all those little windows are in front of any other app you want to look at while coding.) The solution is to set up some shortcut keys that switch you from "Sprawl across two screens" mode to "Pull everything into one screen, dock the little windows, and make the second monitor available for other stuff" mode, and back.

Export Two Sets of Window Settings
You can save Visual Studio settings (such as window layout) to a file, and later import that settings file. For this hack, we'll export two settings files (one for two-screen, sprawl mode; one for one-screen, compact mode). Then, we can switch from one mode to the other by importing the appropriate settings file.

Get your windows how you like them in one-screen mode. For example, my Solution Explorer is a docked pane on the right, unpinned so that it auto-hides; and so on, for the handy windows I want at my fingertips. So, set those up.

Go to Tools > Import and Export Settings... > select the radio button for Export > click Next > uncheck All Settings > expand General Settings > check Window Layouts > click Next. Name the file (e.g., OneScreen.vssettings) and give it a location. Click Finish.

Now set up your windows in two-screen mode. Unhide a window by hovering over it, pin it, right-click on its title bar, and pick Floating. Drag it where you want. This is the artistic phase.

As above, export those settings, with a different name (e.g., TwoScreens.vssettings).

Create Two Switcher Macros
Add a macro module in the Macros IDE (Tools > Macros > Macros IDE), and create two macros, one to import each settings file. Here's my module, called WindowsSettingsSwitcher, which gets my settings files from C:\VSSettings\.

Imports System.IO
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module WindowsSettingsSwitcher
    Public Sub SwitchToWinLayoutTwoScreens()
        DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:C:\VSSettings\TwoScreens.vssettings")
    End Sub

    Public Sub SwitchToWinLayoutOneScreen()
        DTE.ExecuteCommand("Tools.ImportandExportSettings", "-import:C:\VSSettings\OneScreen.vssettings")
    End Sub
End Module

You can test the macros from the Macro Explorer by double-clicking their names.

Assign Shortcut Keys to the Macros
Create some shortcuts that execute those macros. Tools > Options > expand Environment > click Keyboard. In the "Show commands containing" box, enter some text that will find your macros, e.g., "switchtowin" if you used my names above. Highlight a macro, put your cursor in the "Press shortcut keys" box, and type your shortcut. (Mine are Ctrl+Alt+1 for one-screen, and Ctrl+Alt+2 for two-screen, since those weren't in use by anything else.) I left the "Use new shortcut in" set to "Global." Click OK.

At this point, you can use your shortcut keys to switch modes. I added them to my View menu, too, mostly to give me a visual reminder of the shortcuts.

Add Switcher Commands to the View Menu
Tools > Customize > Commands tab > select the "Macros" category. Click and drag your macro from the Commands list in the dialog up to your toolbar. When you hover over View, the View menu will appear, showing the insertion point for your new command. Drop it in place. Right-click on the command in its new location, click on the Name box, and edit that down to something helpful (e.g., "OneScreen"). Repeat to add the other macro. Close the Customize dialog.


With this hack, you can keep lots of useful Visual Studio bits visible (liberating you from relying on the mouse to hover over auto-hiding windows, and maximizing your editor window), but stow them away quickly when you need the second screen for something else.

So how 'bout you? What are your workstation hacks?

Labels: ,

3 Comments:

OpenID Joshua Flanagan said...

Nice one, Sharon.
Another option is to take advantage of the fact that Visual Studio stores window layout positions for at least 3 different modes: normal, fullscreen, and debugging. What this means is you can go into fullscreen mode (Shift+Alt+Enter) and tear off your tool windows and put them on the 2nd monitor. And then in "normal" mode, keep the tool windows docked. Use Shift+Alt+Enter to toggle between the modes.
One benefit of the import/export approach is that even if you change/screwup your window layouts, when you run your macro, it will restore things to the way you had them.
Of course that can also be considered a drawback if you intended to keep your new layout.

10:48 PM  
Blogger Sharon said...

Thanks, Josh. I like yours because it's succinct, accomplishing pretty much the same thing in far fewer steps. Keen.

8:39 AM  
Blogger GabriŽlvdK said...

Hi,

For those of you with a little bit of extra money at their disposal: a third screen is ideal for the situation you're describing.

Layout:
Left screen (Output / Reading):
Browsers, Outlook, Application/Website you're currently debugging, etc.

Center screen (Working screen): Code Editor, Photoshop Image, Dreamweaver code, etc.

Right screen (Panel / Toolbars):
All visual studio panels (Watches, Solution Explorer, Immediate Window, etc., Photoshop Layers/History, Dreamweaver File Explorer, etc..

Just a suggestion!

4:50 AM  

Post a Comment

Links to this post:

Create a Link

<< Home