An image of Hugh Rawlinson's face

Terminal Keyboard Shortcuts in Visual Studio Code

In terminal, I'm used to using the emacs/readline keyboard shortcuts to skip to the beginning and end of lines, and to clear the board. I don't actually use emacs at the moment (though there was a time when Spacemacs was the one for me)

Here's what I expect some specific keyboard shortcuts to do in my terminal. I use fish shell, but based on zero understanding of the underlying system, I wildly assume it all hooks into readline and is managed there, and is therefore the same between bash, zsh, fish, and whatever other prompts or repls use readline.


Move the cursor to the beginning of the input line


Move the cursor to the end of the input line


Clear the screen

So what's the problem?

The problem is that by default in VSCode, ctrl+e triggers a search box for searching for files, which means I can skip backwards, but if I want to get to the end of the line again, I have to hold the right arrow key. This is a pain for cases where I want to paste in a command from a tutorial and go back to fill in variables[1], or even more commonly, just correcting typos.

ctrl+l is also assigned by default in VSCode, so I don't get to quickly clear my screen.

What's the fix?

Overwrite the keybindings.

  1. Open the omni-command-bar-modal with ctrl+p
  2. Use the "Preferences: Open Keyboard Shortcuts (JSON)" option.
  3. Add in the following values:
"key": "ctrl+e",
"command": "ctrl+e",
"when": "terminalFocus"
"key": "ctrl+l",
"command": "ctrl+l",
"when": "terminalFocus"

These values will bind the keyboard shortcuts to issuing the same keyboard shortcut, specifically when the integrated terminal is in focus. This is a nice feature of VSCode, contextual keyboard shortcuts so that you don't need to give them up for the entire editor when you just need them to work in the terminal.

Have you got keyboard shortcut tips? Have I missed some crucial VSCode feature or extension? Let me know on Mastodon! Thanks for reading.

[1]: I should actually be using this fancy edit_cmd function I bind to f4 for this use case, but I sometimes don't do that.