While there are a lot of modal toggles and navigation shortcuts for VS Code, there isn’t one specifically for “move from editor to terminal, and back again”. However you can compose the two steps by overloading the key
and using the when
clause.
Solution
You can achieve the desired effect by adding the appropriate settings to the keybindings.json
file. Here are the required steps:
-
Open the Command Palette (Ctrl+Shift+P Windows/Linux or ⇧ ⌘ P Mac).
-
Type “Preferences: Open Keyboard Shortcuts File” and press Enter.
-
Add the following entries to the
keybindings.json
file:
// Toggle between terminal and editor focus
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus"
},
{
"key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
}
With these shortcuts you can focus between the editor and the Integrated Terminal using the same keystroke.
NOTE
In modern versions of VS Code (as of 2022) the Default Keyboard Shortcuts (JSON) file is read-only, so that is why for the custom settings you need to edit a separate dedicated file keybindings.json
.
More info can be found on the official Visual Studio documentation page:
- Key Bindings for Visual Studio Code: Advanced customization