VS Code Keyboard Shortcuts That Save Hours
The essential VS Code keyboard shortcuts for editing, navigation, multi-cursor, refactoring, and terminal operations that dramatically speed up development.
VS Code Keyboard Shortcuts That Save Hours
The speed difference between a developer who uses keyboard shortcuts and one who reaches for the mouse is enormous. Every mouse movement takes 2-4 seconds when you account for the hand travel, visual targeting, clicking, and returning to the keyboard. Multiply that by hundreds of interactions per day and you lose hours every week.
I have tracked my keyboard shortcut usage across projects. The shortcuts in this guide are the ones that actually show up in daily work — not the 300+ shortcuts in the documentation, but the 40 that matter.
Prerequisites
- VS Code installed
- A keyboard (obviously)
- Willingness to practice for a week before it becomes natural
- Knowledge of your OS keyboard conventions (Ctrl on Windows/Linux, Cmd on macOS)
Note: This guide uses Windows/Linux shortcuts. macOS users should substitute Cmd for Ctrl and Option for Alt in most cases.
Navigation Shortcuts
These shortcuts move you through files and code without touching the mouse.
File Navigation
Ctrl+P Quick Open file by name
Ctrl+Shift+P Command Palette
Ctrl+Tab Switch between open editors
Ctrl+\ Split editor
Ctrl+1/2/3 Focus editor group 1/2/3
Ctrl+W Close current editor
Ctrl+Shift+T Reopen last closed editor
Ctrl+K Ctrl+W Close all editors
Quick Open (Ctrl+P) is the single most important shortcut. Type a few characters of any filename and press Enter. You never need the file explorer for opening files.
Quick Open power features:
Ctrl+P then type:
app.js → opens app.js
route user → matches routes/userRoutes.js
@ → go to symbol in file (same as Ctrl+Shift+O)
# → go to symbol in workspace
:42 → go to line 42 (same as Ctrl+G)
> → command palette (same as Ctrl+Shift+P)
Code Navigation
Ctrl+G Go to line number
Ctrl+Shift+O Go to symbol in current file
Ctrl+T Go to symbol in workspace
F12 Go to definition
Alt+F12 Peek definition (inline preview)
Shift+F12 Find all references
Ctrl+Shift+\ Jump to matching bracket
Alt+Left Navigate back
Alt+Right Navigate forward
Ctrl+Shift+M Toggle Problems panel
F8 Go to next problem/error
Shift+F8 Go to previous problem/error
Go to Definition (F12) and Navigate Back (Alt+Left) form a pair. Jump into a function definition with F12, read it, then jump back with Alt+Left. This is how you explore codebases without getting lost.
In-File Navigation
Ctrl+Home Go to beginning of file
Ctrl+End Go to end of file
Ctrl+Up/Down Scroll without moving cursor
Home Go to beginning of line
End Go to end of line
Ctrl+Left/Right Move by word
Ctrl+Shift+[ Fold code block
Ctrl+Shift+] Unfold code block
Ctrl+K Ctrl+0 Fold all
Ctrl+K Ctrl+J Unfold all
Editing Shortcuts
Line Operations
Ctrl+Shift+K Delete entire line
Alt+Up/Down Move line up/down
Shift+Alt+Up/Down Duplicate line up/down
Ctrl+Enter Insert line below
Ctrl+Shift+Enter Insert line above
Ctrl+] Indent line
Ctrl+[ Outdent line
Ctrl+/ Toggle line comment
Shift+Alt+A Toggle block comment
Move Line (Alt+Up/Down) is one of the most-used editing shortcuts. Select lines and move them around without cutting and pasting.
Duplicate Line (Shift+Alt+Down) creates a copy of the current line below. Faster than copy-paste for creating similar lines.
Selection
Ctrl+D Select word (repeat to select next occurrence)
Ctrl+Shift+L Select all occurrences of current selection
Ctrl+L Select entire line
Shift+Alt+Right Expand selection
Shift+Alt+Left Shrink selection
Ctrl+Shift+K Delete selected lines
Ctrl+D is transformative. Select a variable name, press Ctrl+D repeatedly to select each next occurrence, then type the new name. All occurrences update simultaneously. This is faster than find-and-replace for small renames.
Multi-Cursor
Alt+Click Add cursor at click position
Ctrl+Alt+Up/Down Add cursor above/below
Ctrl+D Add selection for next occurrence
Ctrl+Shift+L Add cursor at all occurrences
Ctrl+U Undo last cursor/selection
Escape Return to single cursor
Multi-cursor editing examples:
Adding the same text to multiple lines:
- Place cursor at the start of a line
Ctrl+Alt+Downto add cursors on lines below- Type — text appears on all lines simultaneously
Renaming a variable in multiple places:
- Double-click the variable name to select it
Ctrl+Dto select the next occurrence (repeat as needed)- Type the new name — all occurrences update
Editing structured data:
- Select a pattern (e.g., a quote character)
Ctrl+Shift+Lto select all occurrences- Edit — all positions update at once
Find and Replace
Ctrl+F Find in file
Ctrl+H Find and replace in file
Ctrl+Shift+F Find in all files
Ctrl+Shift+H Replace in all files
F3 Find next
Shift+F3 Find previous
Alt+Enter Select all matches (in find dialog)
Ctrl+Shift+1 Replace and find next (in replace dialog)
Find and Replace power features:
- Toggle regex mode with
Alt+Rin the find dialog - Toggle case sensitivity with
Alt+C - Toggle whole word matching with
Alt+W Alt+Enterin find mode selects all matches, then you can type to replace them all with multi-cursor
Text Manipulation
Ctrl+Shift+[ Fold region
Ctrl+Shift+] Unfold region
Ctrl+K Ctrl+U Uppercase selection
Ctrl+K Ctrl+L Lowercase selection
Ctrl+Shift+P Then "Transform to Title Case" / "Sort Lines" / etc.
Integrated Terminal
Ctrl+` Toggle terminal
Ctrl+Shift+` Create new terminal
Ctrl+Shift+5 Split terminal
Ctrl+PgUp/PgDown Switch between terminals
Ctrl+C Kill running process (in terminal)
Ctrl+Shift+C Copy selection (in terminal)
Ctrl+Shift+V Paste (in terminal)
Toggle Terminal (`Ctrl+``) is essential. Flip between code and terminal without touching the mouse. The terminal remembers your session.
Sidebar and Panels
Ctrl+B Toggle sidebar
Ctrl+Shift+E Explorer
Ctrl+Shift+F Search
Ctrl+Shift+G Source Control
Ctrl+Shift+D Debug / Run
Ctrl+Shift+X Extensions
Ctrl+J Toggle bottom panel
Ctrl+Shift+M Problems panel
Ctrl+Shift+Y Debug Console
Ctrl+Shift+U Output panel
Refactoring
F2 Rename symbol
Ctrl+. Quick Fix / Code Actions
Ctrl+Shift+R Refactor menu
Shift+Alt+O Organize imports
Rename Symbol (F2) is different from find-and-replace. It understands the code's structure. Renaming a function with F2 updates all references across every file, including imports. Find-and-replace would rename unrelated text that happens to match.
Quick Fix (Ctrl+.) is context-aware. Place your cursor on a problem and press Ctrl+. to see suggested fixes:
- Import missing modules
- Convert to arrow function
- Extract to variable
- Add missing return type
- Fix spelling
- Remove unused variables
Window Management
Ctrl+Shift+N New window
Ctrl+K Ctrl+Left Move editor to left group
Ctrl+K Ctrl+Right Move editor to right group
Ctrl+K Ctrl+Up Move editor to above group
Ctrl+\ Split editor right
Ctrl+K Ctrl+\ Split editor down
Ctrl+K Z Toggle Zen Mode (distraction-free)
Ctrl+Shift+P → "Toggle Word Wrap"
Git Shortcuts
Ctrl+Shift+G Open Source Control
Ctrl+Enter Commit (when in SCM input)
In the Source Control panel:
- Click
+on a file to stage it - Click
-to unstage - Type a message and
Ctrl+Enterto commit
Complete Working Example: Custom Keybindings
Create custom keybindings in ~/.config/Code/User/keybindings.json (or Ctrl+K Ctrl+S → click the file icon):
[
// Run current file
{
"key": "ctrl+shift+r",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "node ${file}\n" },
"when": "editorLangId == javascript"
},
// Toggle minimap
{
"key": "ctrl+k ctrl+m",
"command": "editor.action.toggleMinimap"
},
// Duplicate line down (alternative binding)
{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorHasSelection"
},
// Move to next/previous editor group with Alt+1/2
{
"key": "alt+1",
"command": "workbench.action.focusFirstEditorGroup"
},
{
"key": "alt+2",
"command": "workbench.action.focusSecondEditorGroup"
},
// Quick terminal commands
{
"key": "ctrl+shift+t",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "npm test\n" },
"when": "terminalFocus"
},
// Close all editors in group
{
"key": "ctrl+k ctrl+w",
"command": "workbench.action.closeEditorsInGroup"
},
// Toggle sidebar visibility
{
"key": "ctrl+alt+b",
"command": "workbench.action.toggleSidebarVisibility"
}
]
Conditional Keybindings
The when clause controls when a keybinding is active:
[
// Only in JavaScript files
{
"key": "ctrl+shift+l",
"command": "editor.action.formatDocument",
"when": "editorLangId == javascript"
},
// Only when no text is selected
{
"key": "ctrl+d",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorHasSelection"
},
// Only in the terminal
{
"key": "ctrl+k",
"command": "workbench.action.terminal.clear",
"when": "terminalFocus"
},
// Only in the sidebar
{
"key": "ctrl+n",
"command": "explorer.newFile",
"when": "filesExplorerFocus"
}
]
The Essential 20
If you learn nothing else, learn these. They cover 80% of daily editing:
1. Ctrl+P Open file by name
2. Ctrl+Shift+P Command palette
3. Ctrl+D Select next occurrence
4. Ctrl+Shift+L Select all occurrences
5. Alt+Up/Down Move line
6. Shift+Alt+Down Duplicate line
7. Ctrl+Shift+K Delete line
8. Ctrl+/ Toggle comment
9. Ctrl+` Toggle terminal
10. Ctrl+B Toggle sidebar
11. F12 Go to definition
12. Alt+Left Navigate back
13. F2 Rename symbol
14. Ctrl+. Quick fix
15. Ctrl+Shift+F Search in files
16. Ctrl+H Find and replace
17. Ctrl+W Close editor
18. Ctrl+\ Split editor
19. Ctrl+G Go to line
20. Ctrl+Shift+O Go to symbol
Common Issues and Troubleshooting
Shortcut does nothing or does the wrong thing
Another extension or OS-level shortcut is capturing the key combination first:
Fix: Open Ctrl+K Ctrl+S to see the keyboard shortcuts editor. Search for the key combination to find conflicts. Right-click to change or remove bindings.
Shortcuts differ between OS
macOS uses Cmd where Windows/Linux uses Ctrl:
Fix: VS Code's documentation shows both. Hover over any command in the Command Palette to see its current binding. Or use Ctrl+K Ctrl+S to see all bindings for your OS.
Custom keybindings not working
JSON syntax error in keybindings.json silently breaks all custom bindings:
Fix: Open the file and check for missing commas, unclosed brackets, or duplicate keys. VS Code highlights JSON errors.
Multi-cursor feels wrong
If Ctrl+D selects the wrong occurrence or skips one:
Fix: Use Ctrl+U to undo the last selection. Use Ctrl+K Ctrl+D to skip an occurrence without selecting it.
Best Practices
- Learn five shortcuts per week. Trying to memorize everything at once does not work. Pick five, use them exclusively for a week, then add five more.
- Print a cheat sheet and pin it to your monitor. Remove shortcuts as they become muscle memory.
- Disable the mouse for editing operations. Force yourself to use keyboard shortcuts for a day. The discomfort fades quickly.
- Use
Ctrl+Shift+Pas a fallback. If you forget a shortcut, the command palette lets you search for any action by name. It also shows the shortcut next to each command. - Customize bindings for your workflow. If you run tests constantly, bind it to a single keystroke. The default bindings are generic — make them specific to your work.
- Practice multi-cursor editing.
Ctrl+DandCtrl+Shift+Lare the shortcuts with the highest return on learning investment. They replace dozens of find-and-replace operations. - Keep your hands on the home row. Arrow keys require reaching. Learn
Ctrl+Left/Rightfor word movement andHome/Endfor line boundaries instead.