VS Code shortcut to focus integrated terminal
I have added the following to my keybindings.json
file:
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
"when": "editorFocus"
},
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
"when": "explorerViewletFocus"
}
This covers for me the majority of cases: when my Explorer has focus or when an editor has focus, the same key binding will focus on an existing terminal without toggling it.
You can find all the available when
clauses in the VSCode KeyBindings documentation.
This doesn't conflict with the same keybinding already in use globally for workbench.action.terminal.toggleTerminal
.
What you are looking for is the Terminal: Focus Terminal command. By default it's not assigned to a shortcut but you can easily do this using the keyboard shortcut preferences.
You can also call it from the Command Palette by pressing the F1 and typing Focus Terminal
.
Keep in mind that this command will also create a new integrated terminal window if one is not already active.
To access the keyboard shortcuts preferences, activate the Command Palette by pressing F1 and then type open keyboard shortcuts
. To assign new shortcut for a command, press the +
symbol visible on the left side of a row. Popup will appear where you should record your desired keys.
If the terminal is not already displayed, I hit Ctrl+J.
If the terminal is displayed, I hit Ctrl+J twice.