Custom Keybindings & Key Maps
VS Code's keybinding system is fully programmable. This lesson covers advanced keybinding customization — context-aware bindings, when clauses, and importing Vim/JetBrains layouts.
1The Keybinding Editor
Open Ctrl+K Ctrl+S to see every keybinding. Filter by command name or key chord. Hover a binding to see its when clause. Click the pencil icon to edit, or the + to add a new one.
2keybindings.json
[ { "key": "ctrl+shift+t", "command": "workbench.action.terminal.new", "when": "!terminalIsOpen" }, { "key": "alt+f", "command": "editor.action.formatDocument" } ]
3When Clauses — Context-Aware Bindings
The when property lets a shortcut work only in certain contexts. Useful contexts include: editorTextFocus, terminalFocus, isInDiffEditor, resourceExtname == .ts. Combine them with && and ||.
4Keymap Extensions
Preserve your muscle memory by installing a keymap extension:
- Vim — full modal editing with
:commands - VSCode Neovim — real Neovim embedded in VS Code
- IntelliJ IDEA Keybindings
- Atom Keymap
- Sublime Text Keymap
5Key Chords
VS Code supports multi-key chords — two keystrokes in sequence. The default Ctrl+K bindings are chords (e.g., Ctrl+K Ctrl+S). Define your own: "key": "ctrl+k ctrl+d" for a complex operation.