Does anyone know the keyboard shortcut (Mac and Linux) to switch the focus between editor and integrated terminal in Visual Studio Code.
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.
// Toggle between terminal and editor focus
{ "key": "ctrl+`", "command": "workbench.action.terminal.focus"},
{ "key": "ctrl+`", "command": "workbench.action.focusActiveEditorGroup", "when": "terminalFocus"}
With these shortcuts I will focus between the editor and the Integrated Terminal using the same keystroke.
-
11By far, this is the best answer as the most ergonomically justified solution: extending the existing key binding. Kudos! – mloskot May 25 '17 at 15:53
-
3Thanks, this worked fine and saves a lot of time. For users of international keyboards:
"ctrl+`"
can be specified as"ctrl+oem_3"
. – esel Oct 9 '17 at 12:13 -
4@Roman 1.18.0's behavior is certainly an improvement since when I wrote my answer, but I think the above is still better. The difference is the terminal won't disappear when using the keystroke, only the focus will shift. I happen to like keeping my terminal displayed :) – wgj Nov 19 '17 at 6:34
-
17Note that these shortcuts should be pasted to the
keybindings.json
file. – pseudomarvin Mar 23 '18 at 13:44 -
17Open the keybindings.json from the editor:
CMD-SHIFT-P
->Preferences: Open Keyboard Shortcuts File
. Also a nice resource: code.visualstudio.com/docs/getstarted/keybindings – derFunk Apr 23 '18 at 12:53
A little late to the game but I configured mine as the following in the keybindings.json
:
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
"when": "editorTextFocus"
},
{
"key": "ctrl+`",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "alt+`",
"command": "workbench.action.terminal.toggleTerminal"
}
I wanted separate keys for opening/closing terminal and switching focus back and forth between the windows.
-
3Mapping
alt+`
seems to be buggy - tracked at github.com/Microsoft/vscode/issues/41024#issuecomment-363096692 – Ben Creasy Mar 10 '18 at 6:24 -
1I found
alt
easier to press thanctrl
, so in my configuration it's the other way round. – xji Oct 9 '18 at 17:42 -
-
This is a great proposal, although I opted for keeping the original bindings and using
alt
to switch focus. – Mr. Duhart Jan 3 at 16:43
I configured mine as following since I found ctrl+` is a bit hard to press.
{
"key": "ctrl+k",
"command": "workbench.action.focusActiveEditorGroup",
"when": "terminalFocus"
},
{
"key": "ctrl+j",
"command": "workbench.action.terminal.focus",
"when": "!terminalFocus"
}
I also configured the following to move between editor group.
{
"key": "ctrl+h",
"command": "workbench.action.focusPreviousGroup",
"when": "!terminalFocus"
},
{
"key": "ctrl+l",
"command": "workbench.action.focusNextGroup",
"when": "!terminalFocus"
}
By the way, I configured Caps Lock to ctrl on Mac from the System Preferences => keyboard =>Modifier Keys
.
The default keybinding to toggle the integrated terminal is "Ctrl+`" according to vscode 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" }
-
Perfect, Thanks! I'm looking for the second answer you mentioned. If anyone wondering about the keyboard shortcut to put the focus back to editor then it is: Command + 1 (on Mac) – Abhijeet Mar 14 '17 at 22:59
-
I think
focusPanel
is for the general region (include things like "Problems", "Output" and "Debug Console". There's also an action specifically for the Integrated Terminalworkbench.action.terminal.focus
. – wgj Mar 25 '17 at 5:18
As of version : 1.26.1 (linux), the shortcut is not set by default. To set the shortcut
- open keyboard shortcuts panel [ctrl + k , ctrl + s]
- Search for Focus Terminal
- Set your shortcut
For editor focus is already set by default.
-
As they provide additional keyboard mappings, this answer is simpler and faster – tomekpe Oct 24 '18 at 9:05
Try using ctrl+` to toggles the visibility of the terminal and as a result toggle the focus.
Is not exactly what is asked, but I found it very useful and related.
If someone wants to change from one terminal to another terminal also open in the integrate terminal panel of Visual Studio, you can search for:
Terminal: Focus Next Terminal
Or add the following key shortcut and do it faster with keyboard combination.
{
"key": "alt+cmd+right",
"command": "workbench.action.terminal.focusNext",
"when": "terminalFocus"
},
{
"key": "alt+cmd+left",
"command": "workbench.action.terminal.focusPrevious",
"when": "terminalFocus"
},
I hope it helps someone else.
The answer by Shubham Jain is the best option now using the inbuilt keyboard shortcuts.
to Ctrl + ;
to Ctrl + L
This way you can have move focus between terminal and editor, and toggle terminal all in close proximity.
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
protected by eyllanesc Aug 1 '18 at 11:13
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
ctrl
+ ' ` ' will be the best#-> Linux
– muthukumar Jan 24 '18 at 15:40