Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 763
hanshenrik Avatar asked Dec 09 '25 17:12

hanshenrik


2 Answers

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

like image 180
Jonny Soe Avatar answered Dec 11 '25 22:12

Jonny Soe


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 VSCode settings.json

"files.autoSave": "onFocusChange",
like image 45
hanshenrik Avatar answered Dec 11 '25 22:12

hanshenrik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!