45

In VS Code, is it possible to open the terminals in a separate window? So far my research has pointed to a resounding no, but I'm curious if anyone has a solution or workaround.

starball
  • 20,030
  • 7
  • 43
  • 238
Imonitmedia
  • 591
  • 1
  • 4
  • 8
  • related question: [Visual Studio Code open tab in new window](https://stackoverflow.com/q/43362133/11107541) – starball May 10 '23 at 03:12

12 Answers12

36

Move terminals between windows

It's now possible to move terminals between windows by detaching via Terminal: Detach Session in one and attaching to another with Terminal: Attach to Session. In the future this should help enable cross-window drag and drop!

Lots of changes in v1.58: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_58.md#terminals-in-the-editor-area

For v1.59 moving the terminal changes - including dragging and dropping onto another window, see https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_59.md#drag-and-drop-terminals-across-windows

Drag and drop terminals across windows

Drag terminals from the tabs list or editor area of one window into the tabs list, editor area, or panel of another window.

enter image description here

Terminals in the editor area

Terminals can now be created in or moved to the editor area, enabling a multi-dimensional grid layout that persists and remains visible regardless of panel state.

To use terminals in the editor area, there are several options:

Create via the Create Terminal in Editor Area command.
Move a terminal from the panel to the editor by dragging and dropping from the tabs list.
Running Move Terminal into Editor Area with a terminal focused.
Moving into the editor area via the terminal tab context menu action.

terminals in editors demo

The new terminal.integrated.defaultLocation setting can be set to editor to direct newly created terminals to the editor area by default.

Mark
  • 143,421
  • 24
  • 428
  • 436
  • 1
    I am using Python and when I press F5 to debug it always opens a terminal in the **same window** as my source code. I don't like that. I want F5 to open the terminal in a different window. I guess the best solution is to open the same project and python environment in a different window, and then if I want to debug, I have to Ctrl-K+S in one window, click the other window, and then hit F5. Not very convenient though. – John Henckel Mar 03 '22 at 18:24
  • Just a note: if you work with remote connections only a window that is connected to the same remote can detach/attach or drag'n'drop (which is in effect just detach, attach + position) – Simon Sobisch Mar 09 '23 at 10:57
16

Please Try:

  1. File > Open New Window
  2. Ctrl+Shift+P > Terminal: Create New Terminal in Editor Area

You can add keybinding to the commands at your convenience.

Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87
13

i think that the OP wants to create a separate window for the terminal but still have the separated terminal linked to the code editor in the original window (that's what i want too). so that when you run the code in the editor the output is shown in the terminal in the separate window. but if you simply open up a new window of vscode and either open a terminal there or drag and drop the terminal from the original window into the new window, the new terminal is not the same session of the terminal. it is a separate independent unconnected terminal. running the code in the editor does not show output in the new separate terminal. all you have achieved is creating a new unconnected terminal. which you could have just accomplished by opening up a regular terminal window i.e. the one from windows os main menu, no need even to use vscode.

ronny
  • 131
  • 1
  • 3
8

This answer is now outdated. See this answer for instructions on moving terminal panes between VS Code windows. This answer still works but is no longer a necessary workaround.

You can't detach the panes in VSCode, which IMO is a bit of a pain since Visual Studio can detach panes all day long.

There is a workaround though, you can open a new window in VSCode and maximize the terminal pane in that window.

Maximized Terminal Pane

codewario
  • 19,553
  • 20
  • 90
  • 159
5

One reason you'd want to do this is to have the Python terminal on a second monitor while still being able to use Python interactively (shift+enter way). Attaching/detaching didn't work for me, nor can you open separate terminals.

What you can do is simply resize your one window across the screen borders! Then right click on the terminal tab/header and click Move panel to the left and voila!

Two screen setup

Danferno
  • 472
  • 5
  • 12
2
  1. Create a new window by going to File → New Window.
  2. Open up a new terminal inside of it.
  3. Go to your folder (cd your\projectfolder\path).

And here you are, you have a terminal for your project inside it's own seperate window.

double-beep
  • 5,031
  • 17
  • 33
  • 41
DevMo
  • 21
  • 1
2

Try Сtrl+Shift+c. For me, it opens the folder the script is within in a command prompt window.

2

The ideal case of what you're asking for is tracked by two issue tickets that are still open (not implemented):

You can give those issue tickets a thumbs up reaction to show support for them getting implemented, and subscribe to them to get notified about discussions and updates. But please don't make a "me too" comment. "me too" comments generally come off as annoying to repo maintainers because they clutter up discussion and don't contribute anything of significant value.

As for workarounds, you can create a new and empty VS Code window (with no workspace folder), and drag the terminal from your pre-existing window into that one. You can also detach the session from one VS Code window, and then reattach it into another one (using the Terminal: Detach Session and Terminal: Attach to Session commands in the command palette respectively). See also the user docs.

starball
  • 20,030
  • 7
  • 43
  • 238
1

As far as I know, there is no way to split a terminal window with VS Code. Because I also searched the way a lot. Maybe you imagine like below. enter image description here

Instead, I recommend using the 'Tab' style. That means using the terminal as one of the editing tabs like Python file. It's very convenient for me. enter image description here

You can also find the button like below. enter image description here

Then, you can bind the menu with a shortcut. I prefer to set Ctrl+KM. enter image description here

In the shortcut menu, search "move terminal into editor area" enter image description here

End!

Bongsang
  • 41
  • 4
0

You can change the terminal to be side-by-side instead of below the editor. And then make your window very wide. It is almost as good as having two windows.

  1. Right click on the TERMINAL tab.
  2. Select "Move Views to Side Panel"
  3. Make your window very wide

enter image description here

John Henckel
  • 10,274
  • 3
  • 79
  • 79
0

It seems VS Code allows you to detach the terminal window, but it then will not show the output from the editor of the window you detached it from.

I have spent a while searching, and there is really no workaround other than to just run whatever file you are trying to debug from a separate terminal from the same CWD. This also means you will need to save the file in the window you are editing the file in every time you want to run it. huge pain.

ACB_prgm
  • 57
  • 7
-1

If you are using PowerShell inside the VSCode terminal, why don't you use the PowerShell console from the start menu. It's basically equivalent to using the terminal in separate windows. Hope it helps.Sample