Hack 16. Take Control of Your Workspace

Dock, float, and size your windows, and save a
layout for every mode and mood.
Visual Studio contains many ways to
customize your workspace. Every window can be moved, docked, or
hidden. Visual Studio includes different window layouts for different
modes; modifying a window layout during debug mode will not affect
your window layout while coding. There is even a full-screen mode.
This hack delves into all the ways you can take control of your
workspace.
3.2.1. Window Management
Visual Studio provides a plethora of
windows that you can move around the IDE. Windows have a number of
different states; they can be floating, docked, hidden, or in auto
hide mode. Understanding these different states and how changes you
make are saved is important to getting the most out of the Visual
Studio IDE.
Window state is controlled by right-clicking on the window titlebar
and selecting the state (see Figure 3-1)
or by selecting a window option while the focus is on the window you
want to change. Each of these states affects how the window behaves.
Figure 3-1. Choosing the window state

3.2.1.1 Dockable
This is the
default
state for most windows. When a window is set to be dockable, it can
either float above other windows or be docked to the edges of the IDE
window. To dock a window, you simply need to drag that window and,
following the bold outline, choose where you want the window to be
docked. When a window is docked, it will resize with and react to the
other windows around it (including the IDE main window). Visual
Studio 2005 includes a new method for docking that makes it easier to
determine where that window will actually be docked. Figure 3-2 shows an example of the new docking interface.
Figure 3-2. Visual Studio 2005 docking

The new interface makes it easier to determine where you are docking
something. You can simply move your cursor over one of the blue icons
and the window will dock there. Dropping it in the center circle will
cause it to become a tabbed document along with the source code
files.
Windows can be set to dockable but still be floating windows;
dockable just means that you can dock them if
you want to. Holding Ctrl while dragging the window will prevent it
from docking so you can place it over a dock location without it
docking to that location.
3.2.1.2 Floating
If a window is set to floating, it cannot be
docked. It will float right above the IDE and will always be on top
of any docked windows below it.
3.2.1.3 Hidden
Hiding a window simply means that it is not shown
on your screen anywhere. It is the same as closing the window. If you
hide a window, you can always show it again by going to View and then
selecting the window in that list or under the Other Windows menu
option.
3.2.1.4 Auto hide
Auto hide is a very cool feature that is
best used through the little pin icon that appears on the menu at the
top of each window. Click the pin when the window is docked to hide
it; it will be replaced by a small vertical menu on the side of the
screen. You can then click or hover over the icon on the vertical
menu to make the window slide back into view; it will disappear a few
seconds after you stop using it. Clicking on the pin again will pin
it back on the IDE.
3.2.1.5 Tabbed document
Visual Studio 2005 introduces the ability to add a regular window as
a
tabbed document. To do this,
right-click on the window and choose Tabbed Document from the context
menu or drag the window to the blue round icon in the center, as
shown in Figure 3-2. The window will now appear
next to your code files in the document window.
3.2.2. Window Layouts
As
you move
around and customize your window layout, you may notice that
sometimes your changes are undone or they change in certain
situations. This is because Visual Studio uses different layouts that
are active at different times (debug, full screen, etc.). Window
layouts are stored for each user on a machine in a file called
devenv.xml
.
|
By default, the devenv.xml file contains a
number of different window layouts, including design layouts for each
of the different
languages as well as
debug and full-screen layouts. Any
changes you make to the window layouts are saved in this file and are
remembered the next time you start Visual Studio. When you are in
debug mode, any changes you make to the window layout will affect
only the debug windows layout. Next time you enter debug mode, all of
your windows will be in the same place. The other two main window
layouts are design and full screen.
You can also create your own custom window layouts using the
VSWindowManage power toy [Hack #26] .
3.2.3. Document Window
The document
window is the window you use to edit a file. Each time you open a new
document, a new tab is created on the tab bar across the top of this
window. The document window is one of the places where you will spend
a lot of time when working with Visual Studio, and these shortcuts
and features will make working with the window faster and easier.
You can easily move between open documents using
the Window.
NextDocumentWindow
(Ctrl-Tab or Ctrl-F6) and Window.PreviousDocumentWindow
(Ctrl-Shift-Tab or Ctrl-Shift-F6) commands. These two commands allow
you to quickly switch between documents without the use of a mouse,
and since they are similar to the Windows Alt-Tab command, they are
easy to remember. You can also close the current document window with
the Window. CloseDocumentWindow
(Ctrl-F4) command, also similar to the Alt-F4 command used in
Windows.
The Ctrl-Tab shortcut performs an additional action in Visual Studio
2005. It pops up a dialog (similar to the Windows Alt-Tab dialog)
that shows all of the open documents. This new dialog can be seen in
Figure 3-3.
Figure 3-3. Ctrl-Tab dialog

Using this dialog, you can choose which file to open using the arrow
keys or pressing Ctrl-Tab again. You can also use the arrow keys to
select a tool window that you want to switch to.
3.2.4. Work with Tabs
Tabs
are all over Visual Studio. One of
the most common places you find tabs is when you dock multiple
windows in the same spot. Visual Studio will create a tab list of all
the different windows you have docked. Two
shortcuts can be used to quickly
toggle between tabs. The first is Window.NextTab (Ctrl-PageDown) and the
second is Window.PreviousTab (Ctrl-PageUp). You can use these
shortcuts any time the focus is set on a window that has tabs (for
example, on the Solution Explorer window, you can use these shortcuts
to toggle between the Solution Explorer, class view, etc.).
When in the document view, these commands do not
change the tabs that are across the top of the document window, but
rather the tabs that sometimes appear at the bottom of the document
window. For example, when working with a file type that includes a
designer, such as an ASP.NET file, there are two tabs at the bottom
of the window (one for the design view and one for the HTML view).
Use the keystrokes described in the previous section to move between
the tabs across the top of the windowthese are considered
document windows.
3.2.5. Work with Panes
A
pane
is defined
as any of the windows you can move and dock. The solution explorer,
class view, and task list are all panes. Two commands can be used to
quickly move between all the panes currently open in the IDE:
Window.NextPane (Alt-F6) and Window.PreviousPane (Alt-Shift-F6). Both
of these commands let you move around the IDE quickly and easily,
without picking up your mouse.
3.2.5.1 Split-pane mode
You can
split a document by grabbing the small
bar at the top of the scrollbar with the mouse and then dragging down
or by selecting the Window
two different views for the same source file. Having two views into
the same file is wonderful when you need to compare different parts
of the same file; it is much preferred to having to scroll back and
forth. Figure 3-4 shows an example of split-pane
mode.
Figure 3-4. Split-pane mode

Two
shortcut commands also allow
you to move between split panes: Window.NextSplitPane (F6) and
Window.PreviousSplitPane (Shift-F6). When you are done working in
split-pane mode, you simply need to drag the window separator all the
way up to the top of the window or select the Window
Remove Split Menu option.
3.2.6. Full-Screen Mode
Visual Studio includes a
full-screen mode that can be toggled using
the View.FullScreen command, by either using the
Shift-Alt-Enter keystroke or clicking
View
example of full-screen mode.
Figure 3-5. Full-screen mode

As you can see, full-screen mode hides all the other windows and
provides an incredible amount of space for just coding. I frequently
find myself using full-screen mode whenever I am focusing on writing
code, and I really enjoy the added real estate in the editor window.
The same keystroke (Shift-Alt-Enter) switches you back out of
full-screen mode.