Back to Notes

avatar
Nishant Singh

Software Developer

Custom Shortcut to change focus between VS Code editor and terminal
Sat Apr 20 2024 00:00:00 GMT+0000 (Coordinated Universal Time)

There is no official shortcut assigned in VS code to change the focus between the terminal and the editor, but thanks to the customization options in VS Code you can create a shortcut of your own.

Recollect

Make sure the shortcut which you’re assigning is not being used by VS Code natively or by any external extensions you have installed. Overwriting of pre-assigned or native shortcuts might lead to breaking the combination.

Procedure

 {
         "key": "ctrl+k",
         "command": "workbench.action.terminal.focus"
     },
     {
         "key": "ctrl+k",
         "command": "workbench.action.focusActiveEditorGroup",
         "when": "terminalFocus"
 },
     [
         {
             "key": "ctrl+k",
             "command": "workbench.action.terminal.focus"
         },
         {
             "key": "ctrl+k",
             "command": "workbench.action.focusActiveEditorGroup",
             "when": "terminalFocus"
         },
     ]

You can now finally use the key combination assigned (here ctrl+k) to change focus between your terminal and your editor or even open a new terminal in case one is not already opened in VS Code.