How do I vertically split the same file in Visual Studio editor?
Asked Answered
J

5

28

I want to open the same file in both views, after doing a vertical split of the code editor window, in Visual Studio. How can I do this?

I've tried to create a new vertical tab group but can't figure out how to open the same file in both tabs. I've searched but can't seem to find a solution.

Jocasta answered 16/8, 2019 at 17:52 Comment(0)
N
39

1) Make the file you want to split the active tab in VS

2) Window -> New Window

3) Right click on the new tab you just created and select "New Vertical Tab Group"

3a) Now you should see the two tabs side by side

4) Activate tab 1

5) Window -> Split

6) Activate tab 2

7) Window -> Split

Then you will have a 2x2 view of one file.

Nightjar answered 16/8, 2019 at 19:39 Comment(2)
In Visual Studio 2015 at least this only works for some file types. For example, cshtml files don't allow you to press the New Window button when they're the active tab.Pachyderm
this is more proper now in VS2022. works perfectly fine. +1Suggs
S
8

Alt + W, V

This workaround works for me in windows for VS 2019. Hope this will help.

If you want to split in horizontal press Alt + W, N. Then your file will be duplicated. Then drag that file into the center of the Visual Studio. Then you can see a widget which shows 4 cells. You can drop your file on a cell where you want to place your file.

enter image description here

Schmaltz answered 19/12, 2019 at 11:46 Comment(1)
The vertical split does not duplicate the file, which is the original question. The solution is given by Victor Wilson: select tab then Window => New Window (or CTRL+K, O), and only then right click on the tab then Vertical Group (or Alt + W, V).Doukhobor
O
4

In Visual Studio 2022:

To edit the same file side by side (without actually making a new copy of the file) you:

  1. Right click on one of the files (tabs) and select "New Vertical Document Group" to split the editing window into two vertical parts.
    New Vertical Document Group

  2. Select the file (tab) to edit side by side.

  3. Choose "Window" -> "New Window" from the menu.
    Window -> New Window
    The selected file (tab) is split in to two files (tabs), ending with :1 and :2.
    Note: It's the same file, NOT a copy of the first file.

  4. Drag one of the split files to the other side (editing window).
    Drop File

Orthodox answered 11/10, 2023 at 8:59 Comment(0)
W
1

In Visual Studio 2019, this is easiest:

  1. Close all open file tabs, except the one you want to split.
  2. Alt + W --> "New Window". See two tabs, titled: "file:1" and "file:2", but now only one is visible at a time. No problem...
  3. Right-click either file tab (the top actual tab, not inside the window), select from that context menu --> "New Vertical Document Group"
Wanderjahr answered 10/11, 2023 at 4:37 Comment(0)
B
-3

To see multiple different sections of the same code file side by side, you can use my Task Canvas extension.

Burchell answered 17/8, 2019 at 4:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.