Keybindings
Keyboard shortcuts and customization in VS Code.
Essential Shortcuts
General
| Key | Action |
| Cmd+Shift+P | Command Palette |
| Cmd+P | Quick Open file |
| Cmd+, | Settings |
| Cmd+K+Cmd+S | Keyboard Shortcuts |
| ++cmd+backtick++ | Toggle Terminal |
| Cmd+B | Toggle Sidebar |
| Cmd+J | Toggle Panel |
File Operations
| Key | Action |
| Cmd+N | New File |
| Cmd+O | Open File |
| Cmd+S | Save |
| Cmd+Shift+S | Save As |
| Cmd+W | Close Editor |
| Cmd+Shift+T | Reopen Closed Editor |
Editing
| Key | Action |
| Cmd+X | Cut line (no selection) |
| Cmd+C | Copy line (no selection) |
| Cmd+Shift+K | Delete line |
| Cmd+Enter | Insert line below |
| Cmd+Shift+Enter | Insert line above |
| Alt+Up / Alt+Down | Move line up/down |
| Alt+Shift+Up / Alt+Shift+Down | Copy line up/down |
| Cmd+/ | Toggle line comment |
| Alt+Shift+A | Toggle block comment |
| Cmd+[ / Cmd+] | Outdent/Indent line |
Selection
| Key | Action |
| Cmd+D | Select word / next occurrence |
| Cmd+Shift+L | Select all occurrences |
| Cmd+L | Select line |
| Ctrl+Shift+Cmd+Left / Ctrl+Shift+Cmd+Right | Shrink/Expand selection |
| ++alt+shift+drag++ | Column selection |
Multi-Cursor
| Key | Action |
| ++alt+click++ | Add cursor |
| Cmd+Alt+Up / Cmd+Alt+Down | Add cursor above/below |
| Cmd+D | Add selection to next match |
| Cmd+Shift+L | Add cursors to all matches |
| Esc | Exit multi-cursor |
Navigation
| Key | Action |
| Cmd+G | Go to Line |
| Cmd+Shift+O | Go to Symbol in file |
| Cmd+T | Go to Symbol in workspace |
| Ctrl+G | Go to Line |
| Ctrl+- | Go Back |
| Ctrl+Shift+- | Go Forward |
| Cmd+Shift+\ | Jump to matching bracket |
Search
| Key | Action |
| Cmd+F | Find |
| Cmd+H | Replace |
| Cmd+Shift+F | Search in Files |
| Cmd+Shift+H | Replace in Files |
| F3 / Shift+F3 | Find Next/Previous |
| Enter / Shift+Enter | Find Next/Previous (in find dialog) |
| Alt+Enter | Select all matches |
Code Intelligence
| Key | Action |
| F12 | Go to Definition |
| Alt+F12 | Peek Definition |
| Shift+F12 | Find All References |
| Cmd+K+F12 | Open Definition to Side |
| F2 | Rename Symbol |
| Cmd+. | Quick Fix |
| Ctrl+Space | Trigger Suggest |
| Cmd+Shift+Space | Trigger Parameter Hints |
| Shift+Alt+F | Format Document |
| Cmd+K+Cmd+F | Format Selection |
View
| Key | Action |
| Cmd++ / Cmd+- | Zoom In/Out |
| Cmd+0 | Reset Zoom |
| Cmd+\ | Split Editor |
| Cmd+1 / Cmd+2 / Cmd+3 | Focus Editor Group |
| Cmd+K+Left / Cmd+K+Right | Move Editor to Group |
| Cmd+W | Close Editor |
| Cmd+K+W | Close All Editors |
Terminal
| Key | Action |
| ++ctrl+backtick++ | Toggle Terminal |
| ++ctrl+shift+backtick++ | Create New Terminal |
| Cmd+\ | Split Terminal |
| Cmd+Up / Cmd+Down | Scroll Up/Down |
Custom Keybindings
Opening Keybindings
- Cmd+K+Cmd+S or
- Cmd+Shift+P > "Preferences: Open Keyboard Shortcuts (JSON)"
keybindings.json Structure
[
{
"key": "cmd+k cmd+c",
"command": "editor.action.addCommentLine",
"when": "editorTextFocus"
}
]
Keybinding Properties
| Property | Description |
key | Key combination |
command | Command to execute |
when | Context condition |
args | Command arguments |
Key Modifiers
| Modifier | macOS | Windows/Linux |
| Cmd | cmd | ctrl |
| Ctrl | ctrl | ctrl |
| Alt | alt | alt |
| Shift | shift | shift |
Chord Sequences
{
"key": "cmd+k cmd+c",
"command": "editor.action.addCommentLine"
}
When Clauses
Common contexts:
| Context | Description |
editorTextFocus | Editor has focus |
terminalFocus | Terminal has focus |
inDebugMode | Debugging active |
editorHasSelection | Text is selected |
editorLangId == python | Python file open |
Example:
{
"key": "cmd+shift+t",
"command": "python.runFile",
"when": "editorLangId == python"
}
Remove Default Binding
{
"key": "cmd+k",
"command": "-editor.action.addCommentLine"
}
Common Customizations
Vim-Style Navigation
[
{
"key": "ctrl+h",
"command": "workbench.action.navigateLeft"
},
{
"key": "ctrl+l",
"command": "workbench.action.navigateRight"
},
{
"key": "ctrl+k",
"command": "workbench.action.navigateUp"
},
{
"key": "ctrl+j",
"command": "workbench.action.navigateDown"
}
]
Quick File Operations
[
{
"key": "cmd+shift+d",
"command": "editor.action.copyLinesDownAction"
},
{
"key": "cmd+shift+c",
"command": "workbench.action.files.copyPathOfActiveFile"
}
]
Terminal Shortcuts
[
{
"key": "cmd+t",
"command": "workbench.action.terminal.new",
"when": "terminalFocus"
},
{
"key": "cmd+w",
"command": "workbench.action.terminal.kill",
"when": "terminalFocus"
}
]
Vim Extension
Install Vim extension for modal editing:
- Cmd+Shift+X > Search "Vim"
- Install "Vim" by vscodevim
Vim Settings
{
"vim.useSystemClipboard": true,
"vim.hlsearch": true,
"vim.leader": "<space>",
"vim.normalModeKeyBindings": [
{
"before": ["<leader>", "f", "f"],
"commands": ["workbench.action.quickOpen"]
},
{
"before": ["<leader>", "f", "g"],
"commands": ["workbench.action.findInFiles"]
}
]
}
Vim-Specific Bindings
{
"vim.insertModeKeyBindings": [
{
"before": ["j", "k"],
"after": ["<Esc>"]
}
],
"vim.normalModeKeyBindingsNonRecursive": [
{
"before": ["<leader>", "w"],
"commands": [":w"]
},
{
"before": ["<leader>", "q"],
"commands": [":q"]
}
]
}
Finding Commands
Command Palette
Cmd+Shift+P shows all commands with their keybindings.
Keyboard Shortcuts UI
Cmd+K+Cmd+S to:
- Search commands
- See current bindings
- Record key combination
- Change bindings
Default Keybindings Reference
Cmd+K+Cmd+R opens the default keybindings reference.
Troubleshooting
Keybinding Not Working
- Check for conflicts: Cmd+K+Cmd+S > Search for key
- Check
when clause is satisfied - Check extension keybindings
Find Conflicting Bindings
In Keyboard Shortcuts UI:
- Click "Record Keys" icon
- Press the key combination
- See all commands bound to it
Reset Keybindings
Delete keybindings.json to reset to defaults:
rm ~/Library/Application\ Support/Code/User/keybindings.json
macOS to Windows/Linux
| macOS | Windows/Linux |
| Cmd | Ctrl |
| Alt | Alt |
| Ctrl | Ctrl |
Most shortcuts use Cmd on macOS and Ctrl on Windows/Linux.
VS Code settings sync handles platform-specific keybindings automatically.