644

I am trying to open a tab in a new window in Visual Studio Code so I can move it to another screen. If I drag the tab the other screen, a file is created. Is there a shortcut to open a tab in a new Visual Studio Code window so I can move it to another screen?

CC BY-SA 4.0
3

14 Answers 14

1195

On Windows and Linux, press CTRL+K, then release the keys and press O (the letter O, not Zero).

On macOS, press CMD+K, then O (without holding CMD).

This will open the active file tab in a new window/instance.

CC BY-SA 4.0
20
236

This is a very highly upvoted issue request in Github for Floating Windows.

Until they support it, you can try the following workarounds:

1. Duplicate Workspace in New Window [1]

The Duplicate Workspace in new Window Command was added in v1.24 (May 2018) to sort of address this.

  1. Open up Keyboard Shortcuts Ctrl + K, Ctrl + S
  2. Map workbench.action.duplicateWorkspaceInNewWindow to Ctrl + Shift + N or whatever you'd like

Duplicate Workspace in New Window

2. Open Active File in New Window [2]

Rather than manually open a new window and dragging the file, you can do it all with a single command.

  1. Open Active File in New Window Ctrl + K, O

Open Active File in New Window

3. New Window with Same File [3]

As AllenBooTung also pointed out, you can open/drag any file in a separate blank instance.

  1. Open New Window Ctrl + Shift + N
  2. Drag tab into new window

4. Open Workspace and Folder Simultaneously [4]

VS Code will not allow you to open the same folder in two different instances, but you can use Workspaces to open the same directory of files in a side by side instance.

  1. Open Folder Ctrl + K,Ctrl + O
  2. Save Current Project As a Workspace
  3. Open Folder Ctrl + K,Ctrl + O

For any workaround, also consider setting setting up auto save so the documents are kept in sync by updating the files.autoSave setting to afterDelay, onFocusChange, or onWindowChange

AutoSave

CC BY-SA 4.0
4
42

When I want to split the screens I usually do one of the following:

  1. open new window with: Ctrl+Shift+N
    and after that I drag the current file I want to the new window.
  2. on the File explorer - I hit Ctrl+Enter on the file I want - and then this file and the other file open together in the same screen but in split mode, so you can see the two files together. If the screen is wide enough this is not a bad solution at all that you can get used to.
CC BY-SA 4.0
4
20

With Visual Studio Code 1.43 (Q1 2020), the Ctrl+K then O keyboard shortcut will work for a file.

See issue 89989:

It should be possible to e.g. invoke the "Open Active File in New Window" command and open that file into an empty workspace in the web.

new windows -- https://user-images.githubusercontent.com/900690/73733120-aa0f6680-473b-11ea-8bcd-f2f71b75b496.png

CC BY-SA 4.0
1
11

If the accepted answer isn't working for you, for example, your shortcut key may have been changed to do other things. You can launch the command input by Ctrl + Shift + P, then type 'new window' and you will see the result File: Open active tab in a new window, and select it.

CC BY-SA 4.0
2
7

Press Command+K (wait, it will wait for pressing any key which you can see in the below bar) then press O. So, it is Cmd+k+ O(space represents little wait).

CC BY-SA 4.0
3
5

Just an update, Feb 1, 2019: cmd+shift+n on Mac now opens a new window where you can drag over tabs. I didn't find that out until I when through KyleMit's response and saw his key mapping suggestion was already mapped to the correct action.

CC BY-SA 4.0
1
  • 1
    This is not the same thing as duplicating the workspace, though, because any dependencies or functions from libraries will not be loaded for your linters. A new windows lets you look at files, but it lacks all the functionality of a workspace.
    – mbomb007
    Commented Jan 10, 2020 at 15:26
5

I found a way to achieve the "Duplicate Workspace in New Window" workflow from @mbomb007's workarounds via the command line:

Normally code --new-window <path-to-folder> will not open a new window if that folder is the root of an existing window.

code --new-window <path-to-some-file> followed by code --add <path-to-folder> does the trick. I put a 1s delay between those commands.

Issue #2686 was closed with a recommendation for users to use the "Duplicate Workspace in New Window" workflow, but didn't include a CLI solution. I would have posted this workaround there, but it's locked.

CC BY-SA 4.0
3

I wanted to use my second screen for viewing a preview of a document. None of the suggestions worked well since the preview was not updated in the second window, even when the workspace was duplicated and autosave enabled.

My workaround was to simply increase the size of the window to span both screens, and use the standard split tab.

To expand one window across two screens, I recommend Microsoft PowerToys. The FancyZones feature can be configured to allow zones to span across monitors, so a custom canvas can be created to quickly expand a single window to both screens.

CC BY-SA 4.0
3

You can find all issue tickets related to this feature by filtering with the workbench-auxwindow ("auxiliary windows") label in the issue tracker.

I'll try to keep this answer as up to date as I can with those developments.

VS Code 1.86 update

There's now a "Open Output in New Window" action in the Output Panel's title menu (source), and Notebooks are supported for floating windows (source).

VS Code 1.85 update

You can now drag editor tabs out of a window to create a new window for them. If you want to disable this, use the workbench.editor.dragToOpenWindow setting.

Commands and keybinding command IDs include:

  • View: Copy Editor into New Window (workbench.action.editor.copyWithSyntaxHighlightingAction)
  • View: Move Editor into New Window (workbench.action.editor.moveEditorToNextWindow)
  • View: Copy Editor Group into New Window (workbench.action.editor.copyGroupToNextWindow)
  • View: Move Editor Group into New Window (workbench.action.editor.moveGroupToNextWindow)
  • View: New Empty Editor Window (workbench.action.newWindow)

Terminals and search results are also supported in floating/auxiliary windows now too.

The right click / context menus of editor tabs now have the entries "Move into New Window" and "Copy into New Window".

VS Code 1.83/1.84 update

The VS Code team is now experimenting with implementation of floating windows in the latest VS Code Insiders (source: 1.83 release notes and 1.84 release notes). Quoting from the 1.83 release notes:

All editors across all windows operate on the same underlying editor models, so that changes made in one window are reflected live in all other windows. You can create any editor layout in the floating windows and open any editor you like, in as many windows as you want.

For our first working version, we envision that the Status bar would also be present in the floating windows so that editor information - such as line numbers and selection ranges - is shown. Stay tuned for more development in the coming months!

Currently, there is a command named View: Move Active Editor into a New Window (Experimental) with ID workbench.action.experimentalMoveEditorIntoNewWindowAction (if you want to bind a keyboard shortcut to it).

VS Code 1.82 answer

As for right now in the stable release of VS Code, the best workaround I see is to use the File: Open Active File in New Window command, which is bound by default to ctrl/cmd+k,o, or to manually open a new window, and drag the editor over there. But those aren't great because the file will be opened standalone, without any of the context of the workspace it was opened from (without workspace settings, extensions enabled for that workspace, workspace tasks, project configuration for that workspace, etc.). If you don't want that problem, then you can open the same workspace in a new window. I guess the downside of that could be that it could potentially use more system resources (Ex. extension host, filesystem watchers to keep the multiple windows with the same workspace in sync, etc.).


I thought I'd take the opportunity to highlight comments from the issue ticket that explain what makes this a hard problem to tackle / hard feature to implement (seriously- this is why I tell people not to make "+1" / "bump" comments. that thread is a swamp and an absolute nightmare to try to read through if you want to actually find the meaningful discussion). According to the maintainers, the challenge mostly comes difficult architecture changes and keeping good performance (source).

CC BY-SA 4.0
3
  • 1
    Isn't it basically resolved in 1.85 ? They have closed the issue as completed. Thanks.
    – Hagrid67
    Commented Dec 28, 2023 at 22:01
  • @Hagrid67 The feature will continue being developed and improved upon. See the link in the very first sentence of this answer post. The initial implementation may be considered done, but the feature in general is far from being "finished" and my never be (and that can be a good thing)
    – starball
    Commented Dec 28, 2023 at 22:03
  • As of 1.85, this should be the accepted answer. The only solution that lets you use the debug console in one window and place breakpoints in another one. Commented Jan 8, 2024 at 14:54
2

Thanks to a recent update in VSCode, you can now just drag the file to an empty location and it will popup a new window! (Provided your VSCode version is > v1.85.x)

I am personally running VSCode in WSL2 and it works great for me!

More info here

CC BY-SA 4.0
1
1

Here is a demo - it is available in Insiders now - of the ability to open an editor in a new window as mentioned by @starball.

There is this setting which is enabled by default:

Workbench > Editor: Drag to Open Window
Controls if editors can be dragged out of the window to open them in a new window.  Press and hold Alt-key while dragging to toggle this dynamically.

This means that you could disable that setting but still drag and drop an editor or editor group to create a new file by also holding down the Alt key at the same time.

You can either drag an editor (or an editor group) out of the current window to open all of them in a new window OR use a command on the current editor.

The commands are

View: Move Editor into New Window
workbench.action.moveEditorToNewWindow

workbench.action.experimentalMoveEditorIntoNewWindowAction

View: Move Editor Group into New Window
workbench.action.moveEditorGroupToNewWindow

View: Copy Editor Group into New Window
workbench.action.copyEditorGroupToNewWindow

View: Copy Editor into New Window
workbench.action.copyEditorToNewWindow

Those currently do not have a default keybindings.

In addition, each editor tab's context menu includes 2 new options:

Move into New Window
Copy into New Window

The editor group tab bar also includes these context menu options, see demo:

tab bar context menu move and copy commands

The Copy versions will make another copy of the current edit group or editor in a new window without removing them from the original window.

Tabs can be dragged back and forth between the new window and the main workspaces window. The floating window has no views or panels associated with it - like the SideBar or Panel where the terminal typically lives.

Demo using the editor move command:

move editor to a new floating window 

On a drag and drop (currently on dragging it appears as if it cannot be dropped - ignore that for now, it can be dropped) the new window's top left will be located where it is dropped.

Demo showing dragging an editor group:

drag an editor group to create a new window

Note that to drag an entire group you start from the area to the right of the group - click and drag.

To drag an individual file click and drag from it's tab.

You can have mutiple floating or detached windows open, and you can drag editor tabs between them.

For multiple monitors, you can have the windows on any of the monitors but a new window created by command or context menu option is created on the same window. To actually get a new window to another monitor you have to drag and drop it there.

CC BY-SA 4.0
-1

You can also hit Win+Shift+[n]. N being the position the app is in the taskbar. Eg if it's pinned as the first app hit WIn+Shift+1 and windows will open a new instance and then you can drag the tab over to the new window.

Most convenient workaround for me so far.

CC BY-SA 4.0
-5

If you are using the excellent

VSCode for Mac, 2020

simply tap Apple-Shift-N (as in "new window")

Drag whatever you want there.

CC BY-SA 4.0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.