visual-studio Visual Studio:如何在两个单独的选项卡组中查看同一个文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/444382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:04:01  来源:igfitidea点击:

Visual Studio: How can I see the same file in two separate tab groups?

visual-studio

提问by p4bl0

I want to be able to edit one method while looking at another method in the same file, as reference. Can this be done?

我希望能够在查看同一文件中的另一种方法的同时编辑一种方法,作为参考。这能做到吗?

回答by p4bl0

You can open the file in another tab (Window-> New Window).

您可以在另一个选项卡 ( Window-> New Window) 中打开文件。

Doing so you have two copies of the same file. Then you can right-click the tab bar and select New Vertical Tab Group(or New Horizontal Tab Group, the one you like more).

这样做你有同一个文件的两个副本。然后您可以右键单击标签栏并选择New Vertical Tab Group(或者New Horizontal Tab Group,您更喜欢的那个)。

Hope I understood you question..

希望我理解你的问题..

回答by ctacke

Only vertically that I'm aware. When looking at the code, right above the vertical scroll bar is a small rectangle, drag it down to get a split view of the file.

只有垂直,我知道。查看代码时,垂直滚动条的正上方是一个小矩形,向下拖动可以获得文件的拆分视图。

回答by Hille

Be onthe tab you want to duplicate,
then click in the menu barat the top on
Window> New Window

你要复制的选项卡,
然后单击菜单栏的顶部
Window>New Window

Finally drag & drop the second window to the the left or right side to show both views next to each other.
Et voila, there you have it :)

最后将第二个窗口拖放到左侧或右侧,以显示彼此相邻的两个视图。
等等,你有它:)

image insturction 1image insturction 2

图片说明 1图片说明2

EDIT

编辑

It seems that this function is not implemented in all version of VS.
In my case (V 15.4.2 (2017), V 15.9.7 (2017)& V 16.2.5 (2019)) it just works fine.

好像不是所有版本的VS都实现了这个功能。
在我的情况下 ( V 15.4.2 (2017), V 15.9.7 (2017)& V 16.2.5 (2019)) 它工作正常。

Version 15.9.7

版本 15.9.7

回答by Moayad Hani Abu Rmilah

You simply use the small drag arrows icon at the top right corner of your file window as depicted in the following screenshots:

您只需使用文件窗口右上角的小拖动箭头图标,如下面的屏幕截图所示:

Before dragging

拖动前

After dragging

拖动后

回答by Eric D

1) View the same document side-by-side (with a fix for Visual Studio 2017)

1) 并排查看同一文档(针对 Visual Studio 2017 进行修复)

It is possible to do this using New Windowand New Vertical Tab Group, however, in my Visual Studio 2017 the New Windowcommand was missingfrom the Windowmenu. To use it, first you must addthe command to a menu or assign a shortcut to it.

可以使用New Window和来执行此操作New Vertical Tab Group,但是,在我的 Visual Studio 2017 中,菜单New Window缺少该命令Window。要使用它,首先必须命令添加到菜单或为其分配快捷方式。

To add New Windowto your Windowmenu follow this sequence, starting with the Toolsmenu:

要添加New Window到您的Window菜单,请按照以下顺序,从Tools菜单开始:

Tools> Customize> Commands> Menu Bar> Window> Add Command> Window> New Window

Tools> Customize> Commands> Menu Bar> Window> Add Command> Window>New Window

FYI In the Commandsstep you decide where to put the New Windowcommand. The sequence I gave above puts it unceremoniously at the top of the Windowmenu.

仅供参考 在该Commands步骤中,您决定将New Window命令放在哪里。我上面给出的顺序毫不客气地将它放在Window菜单的顶部。

To view the same document side-by-side

并排查看同一文档

  1. Open the document you want to view side-by-side
  2. Select your recently added New Windowcommand (perhaps it's in Window> New Window)
  3. Right click the new tab and select New Vertical Tab Groupor select that command from the Windowmenu
  1. 打开要并排查看的文档
  2. 选择您最近添加的New Window命令(可能在Window> 中New Window
  3. 右键单击新选项卡并New Vertical Tab GroupWindow菜单中选择或选择该命令

2) View the same document above-one-another

2) 上下查看同一文档

If you wish to view the same document in two views on top of each other use the Window> Splitcommand or click-and-drag the double-arrow at the top of the scroll bar for any window.

如果您希望在彼此顶部的两个视图中查看同一文档,请使用Window>Split命令或单击并拖动任何窗口滚动条顶部的双箭头。

3) Get creative

3)发挥创意

FYI You can even combine the two view options to have three, four or even more views of the same document on a particularly wide monitor. On mine (2560 x 1080) I can comfortably get three side-by-side views going andsplit them vertically, if desired. multiple panes

仅供参考,您甚至可以将两个视图选项结合起来,在特别宽的显示器上查看同一文档的三个、四个甚至更多视图。在我的 (2560 x 1080) 上,如果需要,我可以轻松地获得三个并排视图垂直拆分它们。 多个窗格

回答by A. Akzhigitov

One can install VsVimextension and :sp:vspdoes the trick.

可以安装VsVim扩展并:sp:vsp完成此操作。

回答by VMM

In Visual Studio 15 you can just click inside the document and then "Window → Split"

在 Visual Studio 15 中,您只需单击文档内部,然后单击“窗口 → 拆分”

回答by sportzpikachu

To all readers from 2020+: The top answers are outdated. For a newer fix, right click the file and select Open to the Side. This will make a split view and you can see the same file.

致 2020 年以后的所有读者:最佳答案已过时。对于较新的修复程序,请右键单击该文件并选择Open to the Side. 这将创建一个拆分视图,您可以看到相同的文件。