Open two instances of a file in a single Visual Studio session

前端 未结 15 1547
误落风尘
误落风尘 2020-12-02 03:21

I have a file, xyz.cpp. I want to open two instances of this file in Visual studio (BTW, I am using Visual Studio 2005). Why would I want to do so? I want

相关标签:
15条回答
  • 2020-12-02 03:55

    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]

    1. 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.

      • 64-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic
      • 32-bit OS: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic
    2. Find the value Single Code Window Only and do one of the following:

      • Set it to 0
      • Rename the value
      • Delete the value (use caution!)

    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:

    • Tools > Customize... > Commands > Add Command...
    • Select 'Menu Bar' the select the 'Window' menu in the dropdown
    • Add Command... > Window > New Window > OK

    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_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\Basic]
    "Single Code Window Only"=dword:00000001
    
    0 讨论(0)
  • 2020-12-02 04:01

    Luke's answer didn't work for me. The 'New Window' command was already listed in the customize settings, but not showing up in the .js tabs context menu, despite deleting the registry setting.

    So I used:

    Tools

    Customize...

    Keyboard...

    Scroll down to select Window.NewWindow

    And I pressed and assigned the shortcut keys, Ctrl + Shift + W.

    That worked for me.

    ==== EDIT ====

    Well, 'worked' was too strong. My keyboard shortcut does indeed open another tab on the same JavaScript file, but rather unhelpfully it does not render the contents; it is just an empty white window! You may have better luck.

    0 讨论(0)
  • 2020-12-02 04:02

    For file types, where the same file can't be opened in a vertical tab group (for example .vb files) you can

    • Open 2 different instances of Visual Studio
    • Open the same file in each instance
    • Resize the IDE windows & place them side by side to achieve your layout.

    If you save to disk in one instance though, you'll have to reload the file when you switch to the other. Also if you make edits in both instances, you'll have to resolve on the second save. Visual Studio prompts you in both cases with various options. You'll simplify your life a bit if you edit in only the one instance.

    0 讨论(0)
  • 2020-12-02 04:02

    I came up with a hack that might produce the result intended in the original answer.

    If you have the file you want in two windows in a source control, you can right-click on the file and select compare, you can compare the

    If you do compare you will have a new window Called diff, showing you the contents of you file.

    This is of course not ideal as the diff window will have the diff colors polluting the text. Note: you can compare the file you want to open to and empty file, and then you will have the window in a very ugly green background.

    This is not perfect, it is a hack, but it was the only way I found to really have the same file in two windows.

    0 讨论(0)
  • 2020-12-02 04:03

    With the your file opened, go to command window (menu ViewOther WindowsCommand window, or just Ctrl + Alt + A)

    Type:

    Window.NewWindow
    

    And then

    Window.NewVerticalTabGroup
    

    worked for me (Visual Studio 2017).

    Or using menus:

    Menu WindowNew Window

    Menu WindowNew vertical tap group

    0 讨论(0)
  • 2020-12-02 04:05

    I don't have a copy of Visual Studio 2005, but this process works on Visual Studio 2008:

    1. Open xyz.cpp along with some other file.
    2. Right click on tab header and select new vertical tab group.
    3. Left click on that other file in the first tab group.
    4. Open xyz.cpp through solution explorer again.

    You should now have two instances of file in separate vertical tab groups.

    0 讨论(0)
提交回复
热议问题