VS Code Tip of the Week: Keyboard Shortcuts for Moving Focus

VS Code Tip of the Week: Keyboard Shortcuts for Moving Focus

Nick Taylor's photo
Nick Taylor
·Mar 23, 2022·

2 min read

Play this article

This week's tip of the week is all about configuring some shortcuts that allow you to move focus between the editor and the integrated terminal.

By default, CTRL + ` toggles the integrated terminal. I use this all the time.

I struggled with moving back and forth between the terminal and the current tab in the editor. Toggling the terminal closes the terminal panel, and focus is brought back to the current tab in the editor, but what if you want to toggle between the two without closing the integrated terminal panel?

Thanks to this post on Stackoverflow, I was well on my way to achieving this.

{% embed stackoverflow.com/a/43012779/77814 %}

The only problem with this solution was it hijacked how the original intergrated terminal toggle worked with CTRL + `.

No problem, just add another keyboard shortcut! What I ended up with was the following for my keyboard shortcuts.

{
  ...
  // Toggle between terminal and editor focus
  { "key": "ctrl+`", "command": "workbench.action.terminal.focus" },
  {
    "key": "ctrl+`",
    "command": "workbench.action.focusActiveEditorGroup",
    "when": "terminalFocus"
  },
  // Toggle integrated terminal panel
  {
    "key": "ctrl+escape",
    "command": "workbench.action.terminal.toggleTerminal"
  }
}

So now, toggling between the editor and integrated terminal can be done using CTRL + ` and if I want to close the integrated terminal panel, I use CTRL + ESC.

If you're new to modifying keyboard shortcuts, check out the VS Code official documentation.

Happy VS Coding!

 
Share this