Does anyone know the keyboard shortcut (Mac and Linux) to switch the focus between editor and integrated terminal in Visual Studio Code?
Ctrl+J works; but also shows/hides the console.
I did this by going to setting>Keyboard Shortcuts then in the section where it give a search bar type focus terminal and select the option. It will ask to type the combination which you want to set for this action. DO it. As for editor focus type" editor focus" in the search bar and type your desired key. IF you excellently add a key . it can be removed by going to edit jason as mentioned in above comments
The default keybinding to toggle the integrated terminal is "Ctrl+`" according to VS Code keyboard shortcuts documentation page. If you don't like that shortcut you can change it in your keybindings file by adding something similar to:
{ "key": "ctrl+l", "command": "workbench.action.terminal.toggleTerminal" }
There does not seem to be a default keybinding for simply focusing the bottom panel. So, if you do not want to toggle the bottom panel, you will need to add something similar to the following to your keybindings file:
{ "key": "ctrl+t", "command": "workbench.action.focusPanel" }
Generally, VS Code uses ctrl+j
to open Terminal, so I created a keybinding to switch with ctrl+k
combination, like below at keybindings.json
:
[
{
"key": "ctrl+k",
"command": "workbench.action.terminal.focus"
},
{
"key": "ctrl+k",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
}
]
Here is my approach, which provides a consistent way of navigating between active terminals as well as jumping between the terminal and editor panes without closing the terminal view. You can try adding this to your keybindings.json
directly but I would recommend you go through the keybinding UI (cmd+K cmd+S
on a Mac) so you can review/manage conflicts etc.
With this I can use ctrl+x <arrow direction>
to navigate to any visible editor or terminal. Once the cursor is in the terminal section you can use ctrl+x ctrl+up
or ctrl+x ctrl+down
to cycle through the active terminals.
cmd-J
is still used to hide/show the terminal pane.
{
"key": "ctrl+x right",
"command": "workbench.action.terminal.focusNextPane",
"when": "terminalFocus"
},
{
"key": "ctrl+x left",
"command": "workbench.action.terminal.focusPreviousPane",
"when": "terminalFocus"
},
{
"key": "ctrl+x ctrl+down",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "ctrl+x ctrl+up",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
{
"key": "ctrl+x up",
"command": "workbench.action.navigateUp"
},
{
"key": "ctrl+x down",
"command": "workbench.action.navigateDown"
},
{
"key": "ctrl+x left",
"command": "workbench.action.navigateLeft",
"when": "!terminalFocus"
},
{
"key": "ctrl+x right",
"command": "workbench.action.navigateRight",
"when": "!terminalFocus"
},
The answer by Shubham Jain is the best option now using the inbuilt keyboard shortcuts.
I mapped
to Ctrl + ;
and remapped
to Ctrl + L
This way you can have move focus between terminal and editor, and toggle terminal all in close proximity.