Skip to content

Instantly share code, notes, and snippets.

@adduc
Last active January 27, 2025 22:34
Show Gist options
  • Save adduc/ef09bba1b0722422b4a03a844687cec6 to your computer and use it in GitHub Desktop.
Save adduc/ef09bba1b0722422b4a03a844687cec6 to your computer and use it in GitHub Desktop.

VSCode keybindings for terminal in editor-area

While VSCode supports opening terminals in the editor area, its shortcuts are generally hard-coded to deal with the terminal in the bottom-panel. To change this, we can define keyboard shortcuts to mitigate and make the "ctrl+`" functionality toggle between the terminal and the last editor used.

[
// Override the default keybinding for opening the terminal
{
"key": "ctrl+`",
"command": "noop",
"when": "terminal.active"
},
// When no terminals are open, open a new terminal
{
"key": "ctrl+`",
"command": "workbench.action.terminal.new",
// @see https://github.com/microsoft/vscode/issues/211877#issuecomment-2091519337
"when": "!terminalGroupCount"
// "when": "!terminalCount"
},
// When at least one terminal is open, focus on the terminal
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus",
"when": "terminalCount"
},
// When focus is currently on terminal, switch to the previous editor
{
"key": "ctrl+`",
"command": "workbench.action.openPreviousRecentlyUsedEditor",
"when": "terminalFocus"
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment