VS Code shortcut to focus integrated terminal
Visual Studio-CodeVscode SettingsVisual Studio-Code Problem Overview
UPDATE: This issue fixed in a later version of VS Code (tested 1.41.1) control + ` works for both opening and focusing events
How to focus to the integrated terminal while it is showing?
https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf
There's a shortcut to show the integrated terminal. But that will hide the terminal if it's already open. It would be nice if there's a shortcut to focus on terminal while typing on editor.
Visual Studio-Code Solutions
Solution 1 - Visual Studio-Code
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.
Solution 2 - Visual Studio-Code
If the terminal is not already displayed, I hit Ctrl+J.
If the terminal is displayed, I hit Ctrl+J twice.
Solution 3 - Visual Studio-Code
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
.
Solution 4 - Visual Studio-Code
@ringo-de-smet
The keybindings.json
you shared didn't work for me in @code 1.25.1. I just had to change a little bit:
{
"key": "cmd+y",
"command": "workbench.action.terminal.focus",
"when": "editorFocus"
},
{
"key": "cmd+y",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
}
Solution 5 - Visual Studio-Code
I guess the shortcut to show terminal you are using is CMD+J, it will only show/hide terminal panel. If you want to focus on terminal when it is showing, you can use CTRL+ `
Solution 6 - Visual Studio-Code
Although the accepted answer is best, there is way to focus in the terminal without modifying settings.
If already visible, typing CTRL + ` twice will first close the terminal console, and then reopen with focus in it.
Solution 7 - Visual Studio-Code
I recently want to change this hotkey binding too
Here is what I did on my mac:
1 Open Keyboard Shortcut Editor
Use HotKey: cmd + K + cmd + S
OR visual way: Code -> Preferences -> keyboad Shortcuts
2 Search
View: Toggle Integrated Terminal
3 Edit
Change to your favourite bindings