ChatGPT解决这个技术问题 Extra ChatGPT

Visual Studio Code - Tabs (editors) of the same project in multiple screens

Using multiple screens I normally place multiple classes (files) in different screens, this helps me a lot while refactoring, checking tests and comparing changes. Visual Studio Code does not allow me to drag a tab outside the window and view it in (for example) another monitor. I checked the documentation and plugins, but the only way I found, is to open two windows, pointing to the same project (folder) and put those in different screens. I don't like this solution, that causes also some problem when I watch code changes using TypeScript.

Any suggestion?

I use Windows 10, latest version of VSCode.

There is an issue open in github if you want to upvote it there: github.com/Microsoft/vscode/issues/10121
Thank you, I will do it!

N
Norcino

A solution is to press CTRL+K and after releasing CTRL, press O. This will open the current file in a new window.

There are few things I don't like about this solution: - Drag and Drop does not work - Create a new instance of VS Code resulting in (for me) 180MB of ram used - To open the file it takes to me few seconds (quite slow) - The file remains open in the original window as well

Update 20/03/2019:

There is a feature request you can track here:

https://github.com/Microsoft/vscode/issues/10121

And an explanation about why this is difficult to implement here:

https://github.com/Microsoft/vscode/issues/10121#issuecomment-345770248

Update 20/03/2019:

Another important side effect highlighted by @Mär is that:

the IntelliSense fails to establish references it had when the file was opened in the window, where the entire project is opened


Related to this answer: Press CTRL+SHIFT+N at any time to open a new instance of VS Code, then you can drag tabs into it.
If I follow these instructions and open a new VS Code window using CTRL+K, O, then IntelliSense fails to establish references it had when the file was opened in the window, where the entire project is opened.
in my case ctrl+k just opens search (same as ctrl + f)
@dermoritz do CTRL+SHIFT+P this will open the dialogue at the top, type "Open Keyboard Shortcuts" you might have fiddled with the default configuration. You can change this as you prefer and test also the combination of keys. The name of the shortcut is "Open Active File In New Window". See: code.visualstudio.com/shortcuts/keyboard-shortcuts-windows.pdf
According to the last comment on the issue, this is the number one requested feature. That comment was from late 2018, over 2 years ago now. Who's prioritizing the backlog for VS Code? I get that it might be difficult, but they could have rewritten the whole app in that time, right?
C
Community

The easy way but with the same drawbacks. More ram and resources will be used. Is to wrap your project in a folder.

It's the best possible thing. As by now!

=> Duplicate the workspace.

Open the command pannel ctrl+shift+p or F1. Then write dupl

https://i.stack.imgur.com/cZjd0.png

That's it.

More

https://i.stack.imgur.com/b8MHC.png

Also better more

You can open a new window (ex: ctrl+n)

And then go File > Add Folder To Workspace.

And start adding folders to your new Workspace. You can add any folder, that is already open or not. That's too way great. You can have all the needed folders for example in the second screen.

Happy coding.


One small comment on this: "Open the command pannel ctrl+p. Then write dupl". You should write >dupl I mean > mark is important too.
@SmartWaddles it's my bad. It's kind of a typo (ctrl+shift+p). I'm correcting that. The thing is to open the command pallet (we can open it too with F1). In fact i knew i mad the mistake. I said i will update it. And because i had a heavy work load. I forget. Thank you a lot. It's updated now.
oh, it's ok. Thank you for your comment! :)
my pleasure. Thank you too.
This is helpful and is a good solution to the question.
I
Ivan

I found the following way to work on multiple monitors (important: they must be the same size and resolution):

open a visual studio in windowed mode on the 1st monitor (in my case it is a left monitor) move the window to the (left) top corner stretch window to the 2nd monitor (right) bottom corner split screen by clicking “split editor” several times move the code sections separator to the edge between the monitors

This is old qestion, but such way can be useful for someone. It is not very convenient, but it works. The solution may have already appeared in the VS itself, but I didn't find it.


I used this approach, but is fiddly and doesn't offer the same benefits of having an independent window, such moving it left, right of the screen or minimize/maximize.
This is not bad (+1) but when both displays are not the same size/resolution, then the text content of a second-display part of the window can be too small/big to use.
This solution only works if all monitors directly in-line/horizontal, and the same size/resolution. I have both a 2K and a 4K monitor of different physical sizes and at different heights -- so it simply won't work. Part of the window is either off-screen on the small monitor, or truncated on the big monitor -- neither of which are nice.
I have 2 monitors with the same size, but on both I use Windows taskbar in the middle vertical, so unfortunately it stays on top of the VSCode window in the middle.
a
ak_linus

A little hack I used is to just stretch the editor window to fill both screens and split the view pane between the monitors such that both screens show just one open file.

https://i.stack.imgur.com/08pXT.jpg

This is a cheap hack that works without opening multiple instances of VSC.

It may not be the proper solution, but it works without eating up all my system memory.


This seems to be the only way to have both sides in sync
difficult if monitors are not of same resolution.
V
VonC

Visual Studio Code does not allow me to drag a tab outside the window and view it in (for example) another monitor

Actually, VSCode 1.57 (May 2021, 4 years later) will propose something close:

Improved editor drag and drop across windows Support for dragging editors to other windows was improved in this release. You can now drag diff editors, custom editors and the entire editor group to another window to open the editors there.


I am on 1.56.2 and this is already working, the problem is that you need to first open a new instance of VSCode, and then drop the file there, meaning that the above solution is still the quickest for the first time you want to move a file in a new window (to then move this window in another screen). I it would be nice to really have a drag and drop experience (move tab), from the video (and current behaviour) it looks like is just opening the same file also int the targeted window, creating a duplicate, so not really a D&D
@Norcino OK. I will check if there is any difference in 1.57.
Unfortunately this does not work if using Remote Containers, understandably so, but I use them for all my dev work.
@JustinPhillips True. That is unfortunate.
This seems to be the quickest/easiest method, but this (along with the "Duplicate workspace in new window" answer above) doesn't seem to keep edits to my files in sync. I type in one window and it isn't reflected in the other window (while it does stay in sync across tabs in the same window). I guess I can at least use this as view-only.
R
Rithvik Nishad

My solution was to use Remote-ssh to connect to self and open in another window. This does take extra resources. But I find this comfortable as I don't need to create additional workspace.