Reputation: 4283
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.
Upvotes: 56
Views: 35882
Reputation: 20625
If the terminal is not already displayed, I hit Ctrl+J.
If the terminal is displayed, I hit Ctrl+J twice.
Note: Ctrl is Command on Mac.
Open the Command Palette and search for Preferences: Open Keyboard Shortcuts for details of current keyboard shortcuts.
Some people (and the official shortcuts reference) report that the following work out-of-the-box:
(that's a backtick or grave, not an apostrophe, single-quote, or prime)
As far as I can see, by default as of 1.72.2
and 1.73.0-insider
, this shortcut is not bound by default (on Windows, at least).
This could be because, on Windows, the backtick key on many (most?) PC keyboards is an OEM key (in my case, oem_8
).
If you want to manually add the bindings to toggle between terminal and editor, do this:
Open keyboard shortcuts (Command Palette > Preferences: Open Keyboard Shortcuts)
Find Terminal: Focus Terminal, set your preferred keybinding, and set the When value to !terminalFocus
(right-click > Change When Expression)
Find View: Focus Active Editor Group, set your preferred keybinding (can be same so it acts as a toggle), and set the When value to terminalFocus
.
Upvotes: 70
Reputation: 3654
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
Upvotes: 1
Reputation: 880
@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"
}
Upvotes: 13
Reputation: 483
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
.
Upvotes: 11
Reputation: 4923
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.
Upvotes: 4
Reputation: 81
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+ `
Upvotes: 8
Reputation: 5959
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.
Upvotes: 52