Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I open the same file side by side in a single Visual Studio Code session

Say I'm reading file xyz.py, and as function func_x, which is on line x, calls class_y, which is on line y, I want to see both func_x and class_y at the same time so that I don't have to keep on scrolling up and down to read func_x and class_y. How would I open file xyz.py side by side so that I can read both func_x and class_y at the same time?

Edit: This isn't this, as it doesn't explain how to have the same window side by side.

like image 334
joseph Avatar asked Feb 07 '18 22:02

joseph


People also ask

How do I open the same file twice in Visual Studio code?

First, you can click on the divider bar at the top of the scroll bar on the right side of your editor window. Dragging that bar down divides your code window into two panes (one on top of the other), which you can scroll through independently.

How do you open two projects simultaneously in VS Code?

You can simply do File>New Window and open the other project in the new window. Because after you close VSCODE and launch it again it opens only one of these two windows. But with workspace you keep both.


2 Answers

In the top right of your screen there should be a split editor button that looks like this: split editor button

That should do the trick.

The default keyboard shortcut (on windows) is Ctrl+\

like image 134
Aonghas M Avatar answered Oct 20 '22 19:10

Aonghas M


In Command Palette

(Ctrl or ⌘+Shift+P)

Type split e Enter

(Select View: Split Editor)

In sidebar

Alt+Left-click the file

In editor

Click the Split Editor button (Split Editor) in the upper right corner.

like image 29
Lars Gyrup Brink Nielsen Avatar answered Oct 20 '22 19:10

Lars Gyrup Brink Nielsen