BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2003+

Showing the Same Code in Several Windows

When working with large files it is sometimes necessary to view several areas of the code at the same time. If these areas are far apart, it can be useful to view the same source file in multiple Visual Studio editor windows.

Large Code Files

It is usually better to create small classes and structures with limited lines of code. This is common when adhering to the SOLID principles, particularly the Single Responsibility Principle. However, in some cases large files are unavoidable. For example, when creating user interfaces for Windows Forms applications or complex ViewModels when developing using the Model View ViewModel pattern, which is commonly used with Windows Presentation Foundation.

When you do need to work with large source code files in Visual Studio, you might need to view several areas of the code at the same time. You might decide to split the code editor window for a file so that you can view two areas simultaneously. You could also place bookmarks at key areas in the code and switch between lines as desired.

Another means for viewing several sections of a file at the same time is to simply open an extra window for that file. This method is under-utilised by some developers and can be a real time-saver. To open a new window you must first focus the code file in question. Next, open the Window menu and choose, "New Window". An extra window will be opened for the current code file where supported. The tab for the window will contain the file name and a number that differentiates it from the original. The feature works for C# code files and for several other languages but not for designer windows.

Once you have created the additional window, you can move or dock it into a usable position so that you can see several areas of code. You can continue adding further windows if you need to see more code than is permitted in the initial pair. You can edit code in any of the open windows; all changes are automatically reflected in other windows.

The image below shows the same file opened in two docked windows.

Multiple Visual Studio Windows

27 August 2013