hanshenrik
hanshenrik

Reputation: 21465

In VS Code, how can I open the same file in multiple tabs of the same editor group?

Sometimes I want to open the same file multiple tabs, each tab focusing on a different line/method, in Eclipse this is easy, but I haven't found a way to do it in VS Code? screenshot from Eclipse doing it: enter image description here

Split view isn't enough, right now I'm on a 14" laptop with no extra display available, the laptop screen is too small to comfortably use split view.

Upvotes: 13

Views: 4959

Answers (5)

hanshenrik
hanshenrik

Reputation: 21465

Since Microsoft has no plans to implement the feature request, an alternative solution is to create a symlink of the file: ln -s code.c code.ln.c and have *.ln.c in .git/info/exclude then VSCode threats them as 2 different files, even though editing 1 of them is instantly reflected in the second (-: enter image description here

Edit: this also requires you to put in settings.json

"files.autoSave": "onFocusChange",

Upvotes: 2

Alberico Lima
Alberico Lima

Reputation: 53

On the latest VSCODE version at this moment, v 1.84.2, there is an easy way to open two instances of a file side by side to compare different parts of the content, for example two methods that achieve the same result.

In the vscode explorer open a file as usual, just double clicking on it, then rigth click over the same file on vscode explorer and pick "Open to the Side" menu or alternativelly press Ctrl + Enter.

You will have two tabs with independent vertical scroll to compare different parts of the content.

Upvotes: -1

Jonny Soe
Jonny Soe

Reputation: 379

There is a clunky workaround in the feature request:

  1. In Explorer, right-click the target file, click "Select for Compare"
  2. right-click the same file, click "Compare with Selected"
  3. Toggle inline view for diff

Some links with visual guide to achieve this:

https://www.mytecbits.com/microsoft/dot-net/compare-contents-of-two-files-in-vs-code https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_diffs

P.S. This workaround however can only open 2 tabs of the same file concurrently within the same tab group

Upvotes: 6

Phillip
Phillip

Reputation: 184

You can do this by Split Editor feature in VS Code.

Check the following image for details.

enter image description here

Upvotes: 0

Ocaso Protal
Ocaso Protal

Reputation: 20237

I don't know if there is another solution, but this should work: Right click on the tab and then select Split [Up|Down|Left|Right]:

Split edit window in VS Code

Upvotes: -2

Related Questions