'Toggle between fullscreen editor and terminal in VS Code

As a Windows systems admin, I use PowerShell quite a lot. With the release of PS Core, and the implication that the ISE is dead, I've started to try to use VS Code as my day to day tool. One feature I'm missing from ISE is the ability to swap between the editor and the terminal in fullscreen. I usually kept ISE open and maximized, and used Ctrl+R to swap between editor and terminal as needed. I haven't found a way to maximize the terminal, and swap easily between terminal and editor. I know I can make the terminal take up most of the screen, but a) this still leaves about 2 lines of editor open at the top, and b) there doesn't seem to be an easy way to then maximize the editor. Is there a way to minic the ISE behaviour that I haven't found yet?



Solution 1:[1]

To toggle between a full screen editor and a nearly full screen terminal you can use:

{
    "key": "ctrl+alt+m",
    "command": "workbench.action.toggleMaximizedPanel"
}

with your keybinding of choice to replace the Ctrl-Alt-m : that is mine. You just need to "maximize" the terminal first - pull it up as far as it goes. It will remember that between sessions.


Revisiting this :

As of v1.38 this is now pretty simple. There are two commands that will toggle the panel/editors to full screen.

Pick some keybinding to use for the toggle trigger:

{
    "key": "ctrl+alt+q",
    "command": "workbench.action.toggleMaximizedPanel",
    // "command": "workbench.action.toggleEditorVisibility"  either one
    "when": "!terminalFocus"
},

The above will expand the panel or editor to full height, but toggling back will return the panel to its original size but not to nothing. If you want the terminal to bounce between full open and full closed try both of these keybindings:

{
  "key": "ctrl+alt+t",  // you could use     "key": "ctrl+`",  if you wish
  "command": "workbench.action.closePanel",
  // "when": "terminalFocus"
},
{
  "key": "ctrl+alt+t",
  "command": "workbench.action.toggleMaximizedPanel",
  "when": "!terminalFocus"
},

The order of the above 2 keybindings is important.

toggle terminal demo


v1.50 is adding the setting panel.opensMaximized - I tried its different options but couldn't get a simpler result than the two keybindings ctrl+alt+t version I showed above. In any case, start with the panel closed for it to work well.

Solution 2:[2]

The below outlines my solution after reading @Mark 's answer, as it's slightly different. I use ctrl-alt-m to switch between a full-sized terminal and full-sized editor.

note: this includes the mentioned integrated terminal and vscode application menu bars.

For posterity's sake, I'm on vscode version 1.40.1.

Implementation

You'll need to add to your keybindings within vscode and execute a manual step.

keybindings.json

Add this to your keybindings.json file, accessible via the Keyboard Shortcuts editor:

    {
        "key": "ctrl+alt+m",
        "command": "workbench.action.toggleMaximizedPanel",
        "when": "!terminalFocus"
    },
    {
        "key": "ctrl+`",
        "command": "-workbench.action.terminal.toggleTerminal",
        "when": "!terminalFocus"
    },
    {
        "key": "ctrl+alt+m",
        "command": "workbench.action.terminal.toggleTerminal",
        "when": "terminalFocus"
    }

Slide down the integrated terminal

Once you've done this and saved your keybindings.json file you need to manually slide down the integrated terminal all the way off the screen on the bottom, after opening from your editor with ctrl+`.

Afterwards, you should be able to use ctrl+alt+m in your editor and your terminal to get a full-screen-ish experience moving between them.

I've tested this on Ubuntu and Fedora locally as hosts and using remote-ssh to an Ubuntu remote from a Windows 10 host. This has the added benefit of allowing you to get the by-default smaller terminal from within your editor using ctrl+` but use a single command, ctrl+alt+m, for switching between editor/terminal. YMMV!

Solution 3:[3]

Solution 1: Create Terminal in new Tab and Switch Between Tabs

Ctrl+Shift+P > Terminal: Create New Terminal in Editor Area create a terminal as a new Tab (A.k.a. Editor). It looks like:

enter image description here

Now you can toggle between Tabs (A.k.a. Editors) and Terminal (Which is in a new Tab) using View: Quick Open Previous Recently Used Editor in Group

Solution 2: Create Terminal in new Editor Group and Switch Between Editor Groups

Ctrl+Shift+P > Terminal: Create New Terminal in Editor Area to the Side create a terminal in new Editor Groups. It looks like:

enter image description here

Now you can toggle between window and terminal using View: Navigate Between Editor Groups

NOTE:

You can add keybinding to the commands as per your convenience. For example, in case of Solution 1:

{
    "key": "ctrl+`",
    "command": "workbench.action.createTerminalEditor"
},
{
    "key": "ctrl+tab",
    "command": "workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
    "when": "!activeEditorGroupEmpty"
},
{
    "key": "ctrl+w",
    "command": "workbench.action.terminal.killEditor",
    "when": "terminalEditorFocus && terminalFocus && terminalHasBeenCreated && resourceScheme == 'vscode-terminal' || terminalEditorFocus && terminalFocus && terminalProcessSupported && resourceScheme == 'vscode-terminal'"
}

Here, Ctrl+W & Ctrl+Tab are set by default. I just modified Ctrl+`.

The above keybinding will

  • Create terminal when you press Ctrl+`
  • Close terminal when you press Ctrl+W
  • Toggle between fullscreen editor and terminal when you press Ctrl+Tab

Solution 4:[4]

Opening the terminal in VS Code in full screen

This solution will replace the standard keybindings in VS Code so the terminal toggles in full screen.

Implementation

Open command palette ctrl+shift+p and search for Preferences: Open Keyboard Shortcuts (JSON) and paste this between the square brackets.

{ "key":"ctrl+j", "command":"workbench.action.toggleMaximizedPanel","when":"!terminalFocus" },
{ "key": "ctrl+oem_3", "command":"workbench.action.toggleMaximizedPanel", "when":"!terminalFocus" }

Solution 5:[5]

There is now an extension for exactly this. It is the "maximizeterminal" extension by Samuel T Scott. It redefines ctrl+` for opening terminal full-screen. The above keybinding methods, are also great, but in my experience they tend to not work properly once you start opening files by using cli like "code app.js". While using the extension such problems do not occur.

Solution 6:[6]

For macOS users, you can set the shortcut in the same keybindings.json file.

  • You can access the file using the shortcut cmd+shift+p, then write/select Preferences: Open Keyboard Shortcuts (JSON).

  • In keybindings.json, paste the following code between the square brackets:

    { "key": "cmd+alt+m",
       "command": "workbench.action.toggleMaximizedPanel",
       "when": "!terminalFocus" }
    

You can change the shortcut to whatever suits you (mind rewriting any of the default ones!), but I set mine to the same as others suggested (cmd+option+m) to keep a "standard".

Solution 7:[7]

Right click on the terminal instance name at the top as seen below and then select "move terminal into editor area". This will allow you to have a full workspace view within VS Code.

Image of process

Solution 8:[8]

I love this question, I believe I figured out something or at least got the behavior I was looking for.

Using the workspace setting here: https://github.com/microsoft/vscode/issues/107624

(enter ctrl+, and search "openmaximized" and set the dropdown to "always")

From there I set the keyboard shortcut for "Toggle Terminal" to ctrl+j (or whatever you may prefer) and now when I toggle my terminal it goes from full screen to toggled off

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Jason R Stevens CFA
Solution 3
Solution 4
Solution 5 Kartikey Tewari
Solution 6
Solution 7 Tricepticon
Solution 8 jschleicher