Open two instances of a file in single Visual Studio session
I have a file a xyz.cpp. I want to open two instances of a this file in Visual studio (btw I am using 2005). Why would I want to do so? I want to compare two sections of the same file side by side. I know workarounds such as:
Make a copy of the file. But the problem is that its not elegant and I dont want to make copies everytime I faced with this.
I can split the window into two. The problem with split it than I can split it horizontally only. The result of horizontal split is that right half my screen is white space.
If I were able to split it vertically or open two instances of the same file, it would increase the number of lines of code I can compare.
Here's how to do it ...
Select the tab you want two copies of
Select Window
> New Window
from the menu.
New Vertical Tab Group
If New Window
is not listed in the Window
menu note that the command does exist, even as of Visual Studio 2017. Add it to the Window
menu using Tools
> Customize
> Commands
. At that point decide where to put the New Window
command and select Add Command
.
For Visual Basic, HTML and JScript and RDL Expression, the Window > New Window
option mentioned in PaulB's answer is disabled. However an option can be changed in the Registry to enable the menu item.
All other languages do not restrict to a single code window so you can use PaulB's answer without editing the registry.
Enabling New Window in Windows Registry. [1] [2]
Go to the following registry key. This example is for Basic (Visual Basic), but the key is also there for HTML, JScript and RDL Expression.
HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0LanguagesLanguage ServicesBasic
HKEY_LOCAL_MACHINESOFTWAREMicrosoftVisualStudio10.0LanguagesLanguage ServicesBasic
Find the value Single Code Window Only
and do one of the following:
This will enable the "New Window" menu item, but it may still not be visible in the menu.
Adding Menu Item
To actually see the New Window menu item I had to add it back into the menu:
Restoring Registry Value
Copy-paste this to notepad, save as a .reg file and import the file into your registry to restore the initial setting.
[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftVisualStudio10.0LanguagesLanguage ServicesBasic] "Single Code Window Only"=dword:00000001
Open the file (it you are using multiple tab groups, make sure your file is selected).
Menu: Window --> Split (alternately, there's this tiny nub just above the editor's vertical scroll bar - grab it and drag down)
This gives you two (horizontal) views of the same file. Beware that any edit-actions will reflect on both views.
Once you are done, grab the splitter and drag it up all the way (or Menu: Window --> Remove Split)
链接地址: http://www.djcxy.com/p/85428.html