Home > Sample chapters > Programming > Visual Studio and .NET

Working with Documents in Microsoft Visual Studio

04.09 Multiple Views of the Same Document

WINDOWS

Alt,W, N

MENU

Window | New Window

COMMAND

Window.NewWindow

VERSIONS

2005, 2008, 2010

CODE

vstipEnv0016

Sometimes you might want to look at a particularly large document in several different areas at the same time. For example, you might want to look at the same document on multiple monitors. This tip shows you how to make this happen.

Special Note for VB Users in Visual Studio 2010

This feature is turned off by default in VB. A lot of history and reasoning is behind this, but the long and short of it is that this was fixed for 2010 but time ran out and it wasn’t tested. So you can turn this on for VB, but you do so at your own risk. Special thanks to my friend Dustin Campbell for supplying the history and the fix.

To to fix this, go to “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic\” and rename the Single Code Window Only registry key to something like [your initials here] Single Code Window Only. The following illustration shows what I did:

httpatomoreillycomsourcemspimages899222.png
httpatomoreillycomsourcemspimages899224.jpg

Now restart Visual Studio, and you are good to go for the rest of this tip.

Multiple Views

I came across this while I was checking my email one day and noticed a thread started by the legendary Deborah Kurata concerning the Window | New Window menu item. The following example describes how it works.

Open a document window.

httpatomoreillycomsourcemspimages899226.png

Now go to Window | New Window on the menu bar to open a duplicate window of the current document.

httpatomoreillycomsourcemspimages899228.jpg

Notice that “:1” is added to the existing document tab text and that “:2” is appended to the name on the new document tab. You can apparently do this forever (or at least up to 150, which is as high as I have tested this feature).

httpatomoreillycomsourcemspimages899230.png