VS Code Cheat Sheet
Shortcuts for Windows / Linux. On macOS: Ctrl → ⌘, Alt → ⌥ (exceptions noted). Everything is searchable in the Command Palette, and you can change keys with Ctrl + K Ctrl + S.
On this page
The Big Ones #
| Shortcut | Action |
|---|---|
Ctrl + Shift + P or F1 | Command Palette (every command) |
Ctrl + P | Quick Open a file by name |
Ctrl + , | Settings |
Ctrl + K Ctrl + S | Keyboard shortcuts |
Ctrl + ` | Toggle terminal (mac: ⌃ `) |
Ctrl + Shift + ` | New terminal |
Ctrl + B | Toggle the sidebar |
Ctrl + J | Toggle the bottom panel |
Sidebar Views #
| Shortcut | Action |
|---|---|
Ctrl + Shift + E | Explorer |
Ctrl + Shift + F | Search in all files |
Ctrl + Shift + H | Replace in all files |
Ctrl + Shift + G | Source Control (Git) |
Ctrl + Shift + D | Run & Debug |
Ctrl + Shift + X | Extensions |
Editing Lines #
| Shortcut | Action |
|---|---|
Alt + ↑/↓ | Move the line up / down |
Shift + Alt + ↑/↓ | Copy the line up / down |
Ctrl + Shift + K | Delete the line |
Ctrl + X (no selection) | Cut the whole line |
Ctrl + Enter / Ctrl + Shift + Enter | Insert a line below / above |
Ctrl + / | Toggle line comment |
Shift + Alt + A | Toggle block comment |
Ctrl + ] / Ctrl + [ | Indent / outdent |
Shift + Alt + F | Format document |
Ctrl + K Ctrl + F | Format selection |
Alt + Z | Toggle word wrap |
Multi-Cursor & Selection #
| Shortcut | Action |
|---|---|
Alt + Click | Add a cursor |
Ctrl + Alt + ↑/↓ | Add a cursor above / below (mac: ⌥ ⌘ ↑/↓) |
Ctrl + D | Select the next occurrence of the word |
Ctrl + K Ctrl + D | Skip this occurrence |
Ctrl + Shift + L | Select all occurrences |
Shift + Alt + I | Cursor at the end of every selected line |
Shift + Alt + drag | Column (box) select |
Shift + Alt + →/← | Expand / shrink the selection |
Ctrl + U | Undo the last cursor action |
Esc | Back to one cursor |
Code Intelligence #
| Shortcut | Action |
|---|---|
Ctrl + Space | Trigger suggestions |
Ctrl + . | Quick fix / refactor (the lightbulb) |
F2 | Rename symbol everywhere |
F12 | Go to definition |
Alt + F12 | Peek definition |
Shift + F12 | Show references |
Ctrl + Shift + O | Go to a symbol in the file (@) |
Ctrl + T | Go to a symbol in the workspace (#) |
Ctrl + G | Go to line (mac: ⌃ G) |
Ctrl + Shift + \ | Jump to the matching bracket |
Alt + ←/→ | Go back / forward (mac: ⌃ - / ⌃ ⇧ -) |
F8 / Shift + F8 | Next / previous problem |
Ctrl + Shift + M | Problems panel |
Ctrl + K Ctrl + I | Show hover info |
Files, Tabs & Layout #
| Shortcut | Action |
|---|---|
Ctrl + N / Ctrl + S | New file / save |
Ctrl + K S | Save all |
Ctrl + W | Close the tab |
Ctrl + Shift + T | Reopen the closed tab |
Ctrl + Tab | Switch between recent tabs |
Ctrl + \ | Split the editor |
Ctrl + 1 / 2 / 3 | Focus editor group 1 / 2 / 3 |
Ctrl + K Z | Zen mode (Esc Esc to exit) |
Ctrl + = / Ctrl + - | Zoom in / out |
Folding #
| Shortcut | Action |
|---|---|
Ctrl + Shift + [ / ] | Fold / unfold the region |
Ctrl + K Ctrl + 0 | Fold all |
Ctrl + K Ctrl + J | Unfold all |
Find & Replace #
| Shortcut | Action |
|---|---|
Ctrl + F / Ctrl + H | Find / replace in the file |
Alt + Enter (in Find) | Select all matches as cursors |
Alt + C / Alt + W / Alt + R | Toggle case / whole word / regex |
Debugging #
| Shortcut | Action |
|---|---|
F5 | Start / continue |
Shift + F5 | Stop |
Ctrl + Shift + F5 | Restart |
F9 | Toggle breakpoint |
F10 / F11 / Shift + F11 | Step over / into / out |
Emmet (HTML/CSS) #
Type then Tab | Result |
|---|---|
! | HTML5 boilerplate |
ul>li.item*3 | <ul> with 3 <li class="item"> |
div.card>h2+p | Card with a heading and paragraph |
a[href=#]{Click} | Link with text |
Command Line (code) #
| Command | Action |
|---|---|
| Open the current folder | |
| Open in the existing window | |
| Open at line 42 | |
| Compare two files | |
| Install an extension |
Useful Settings (settings.json) #
{
"editor.formatOnSave": true,
"files.autoSave": "onFocusChange",
"editor.minimap.enabled": false,
"editor.linkedEditing": true, // rename HTML tag pairs together
"editor.stickyScroll.enabled": true,
"explorer.confirmDragAndDrop": false
}
codeVS Code from the command line. code [options] [paths…]
| Option | What it does |
|---|---|
code . | Open the current folder |
-r, --reuse-window | Open in the last active window |
-n, --new-window | Open in a new window |
-g file:line[:col] | Go to a line: code -g app.js:42 |
-d a b, --diff | Compare two files |
-m a b base result | Three-way merge |
-a folder | Add a folder to the current window |
-w, --wait | Wait until the file is closed (Git editor: code --wait) |
--install-extension id | Install an extension (--uninstall-extension to remove) |
--list-extensions | Installed extensions (--show-versions for versions) |
--profile "Name" | Open with a profile |
--disable-extensions | Start without extensions (troubleshooting) |
-v | Version |
Nothing on this sheet matches “”.