Last updated: Apr 6, 2024
Reading time·3 min
To switch focus between the terminal and the editor in VS Code:
On Windows and Linux:
Ctrl
+ ` (backtick) to focus the terminal.Ctrl
+ 1
to focus the editor.The ` (backtick) key and 1 are next to one another. The backtick key is right below the Esc key.
On macOS:
Ctrl
+ ` (backtick) to focus the terminal.Cmd
+ 1
to focus the editor.The ` (backtick) key and 1 are next to one another.
You can view the Ctrl
+ ` action in
this table in the docs.
The command is called Toggle Integrated Terminal.
The Ctrl
(or Cmd
) + 1 action can be viewed in
this table.
The command is called Focus into First Editor Group.
There is also a Ctrl
+ 2 (or Cmd
+ 2) keyboard shortcut if you want to focus
the second editor group when using a split screen.
Here is a short clip that demonstrates how this works.
Ctrl
+ ` (backtick) key combinationIf you don't mind closing the terminal view, you can simply press Ctrl
+ `
(backtick) to toggle the terminal which is much more convenient.
The Ctrl
+ ` (backtick) command toggles the integrated terminal.
The first time you press the key combination, it opens the terminal and focuses it.
If you press it again, it closes the terminal and focuses the editor.
The terminal keeps running in the background, so toggling it is quite fast.
If you want to set a custom keyboard shortcut that allows you to switch focus between the terminal and the editor:
Ctrl
+ Shift
+ P
on Windows and Linux.Command
+ Shift
+ P
on macOS.F1
to open the Command Palette.keybindings.json
file.[ // Switch focus between terminal and editor { "key": "ctrl+`", "command": "workbench.action.terminal.focus" }, { "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" } ]
Note: If you already have keybindings in the file, remove the enclosing square brackets and only add the objects.
// Switch focus between terminal and editor { "key": "ctrl+`", "command": "workbench.action.terminal.focus" }, { "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus" }
The first keyboard shortcut is used to focus the terminal and the second uses a
when
clause to focus the editor when the terminal is focused.
The keyboard shortcuts use the Ctrl
+ ` (backtick) key combination but you can
specify any other key combination.
Here is a short clip that demonstrates how this works.
There is also a Toggle Panel Visibility command that is bound to the following keyboard shortcut:
Ctr
+ J
.Cmd
+ J
.The command toggles the visibility of the bottom panel and focuses it.
However, the command doesn't necessarily focus the terminal.
For example, if you previously had the Problems or Output tab focused, you won't switch focus to the terminal when you press the keyboard shortcut.
On the other hand, the Toggle Integrated Terminal command which is bound to
Ctrl
+ ` (backtick) always focuses the terminal.
I've also written an article on how to switch to the previous/next tab in VS Code.
You can learn more about the related topics by checking out the following tutorials: