in Web

Visual Studio Code Keyboard Shortcut to Toggle Between an Open Terminal and Editor


If you are using VS Code, you probably already know that you can open and close the integrated terminal with the default keyboard shortcut of Ctrl + ` or ^ + ` (Mac).

By default, the focus changes, or toggles, between the editor and a terminal when opening/closing the terminal with the shortcut listed above. So toggling between the editor where you are writing your code, and the terminal where you are executing commands, etc, consists of closing and reopening the terminal in order to change focus.

If you’re like me, you want to leave the terminal open all (or most) of the time, and would rather not have it open and close just to change focus. What if you want to either 1) open a terminal if it isn’t already, or 2) toggle between the editor and an already-opened terminal with a command.

Well friend, I’ve finally found out how to do just that.

First, open your keybindings.json file alt+k alt+s, then you can add the following two entries to be able to toggle the focus between an editor and opened terminal (and have it remain open). ­čĹŹ

VS Code Keybinding to Toggle Focus Between and Editor and Terminal

        "key": "ctrl+`",
        "command": "workbench.action.terminal.focus",
        "when": "!terminalFocus"
        "key": "ctrl+`",
        "command": "workbench.action.focusActiveEditorGroup",
        "when": "terminalFocus"

Thank you, @Tyriar!

Bonus: Printable VS Code Keyboard Shortcut Cheat Sheet

When getting the hang of a new IDE, I tend to want a cheat sheet sitting on my desk that I can quickly refer to when I need to know how to toggle full screen or something simple. There’s a handy keyboard shortcut for just that alt+k alt+r or check out the links below:

macOS Version or Windows.