Open two instances of a file in a single Visual St

2019-01-12 13:35发布

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 to compare two sections of the same file side by side. I know workarounds such as:

  1. Make a copy of the file. But the problem is that it's not elegant, and I don't want to make copies every time I am faced with this.

  2. I can split the window into two. The problem with split it that I can split it horizontally only. The result of a horizontal split is that the right half of 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.

13条回答
地球回转人心会变
2楼-- · 2019-01-12 14:06

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.

查看更多
一纸荒年 Trace。
3楼-- · 2019-01-12 14:07

You can use the WindowsNew Window option to duplicate the current window. See more at: Why I like Visual Studio 2010? Undock Windows

查看更多
Fickle 薄情
4楼-- · 2019-01-12 14:07

Window menu, New Horizontal/Vertical Tab Group there will do, I think.

查看更多
姐就是有狂的资本
5楼-- · 2019-01-12 14:07

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.

查看更多
劫难
6楼-- · 2019-01-12 14:08

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.

查看更多
Juvenile、少年°
7楼-- · 2019-01-12 14:09

Open the file (if you are using multiple tab groups, make sure your file is selected).

Menu WindowSplit (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 WindowRemove Split).

查看更多
登录 后发表回答