VS Code Cheat Sheet
Visual Studio Code reference: command palette, keyboard shortcuts, multi-cursor, snippets, settings.json, tasks.json, terminal, and extensions.
Visual Studio Code stays out of the way until you need it. The command palette reaches every feature, the settings are plain JSON, and the integrated terminal shares the editor's keymap. Learn the shortcuts for the actions you do twenty times a day, then add a JSON formatter and a language server — those two cover most of the value.
Command Palette and Quick Open
The Command Palette is the entry point to every built-in command, every extension command, and every keyboard shortcut. Quick Open is the file finder. Bind both to memory.
| Action | Windows / Linux | macOS |
|---|---|---|
| Open Command Palette | Ctrl+Shift+P | Cmd+Shift+P |
| Quick Open file | Ctrl+P | Cmd+P |
| Go to symbol in file | Ctrl+Shift+O | Cmd+Shift+O |
| Go to symbol in workspace | Ctrl+T | Cmd+T |
| Open recent | Ctrl+R | Cmd+Shift+P then Recent |
| Toggle terminal | Ctrl+` | Ctrl+` |
| Toggle sidebar | Ctrl+B | Cmd+B |
| Toggle panel | Ctrl+J | Cmd+J |
Type > in Quick Open to drop into command mode; type @ to jump to symbols; type # to filter open editors by name. The fuzzy match covers file paths, recent edits, and recently opened folders.
Essential keyboard shortcuts
The shortcuts below are the ones that compound. Cmd/Ctrl+D is the single biggest productivity unlock because it builds multi-cursor selections token by token.
| Action | Windows / Linux | macOS |
|---|---|---|
| Multi-cursor: next match | Ctrl+D | Cmd+D |
| Multi-cursor: skip match | Ctrl+K Ctrl+D | Cmd+K Cmd+D |
| Select all matches | Ctrl+Shift+L | Cmd+Shift+L |
| Insert cursor at click | Alt+Click | Option+Click |
| Column selection | Shift+Alt+Drag | Shift+Option+Drag |
| Move line up / down | Alt+↑ / Alt+↓ | Option+↑ / Option+↓ |
| Copy line up / down | Shift+Alt+↑ / Shift+Alt+↓ | Shift+Option+↑ / Shift+Option+↓ |
| Toggle line comment | Ctrl+/ | Cmd+/ |
| Toggle block comment | Shift+Alt+A | Shift+Option+A |
| Go to definition | F12 | F12 |
| Peek definition | Alt+F12 | Option+F12 |
| Rename symbol | F2 | F2 |
| Format document | Shift+Alt+F | Shift+Option+F |
| Format selection | Ctrl+K Ctrl+F | Cmd+K Cmd+F |
| Split editor | Ctrl+\ | Cmd+\ |
| Move editor group | Ctrl+K ←/→ | Cmd+K ←/→ |
| Close all editors in group | Ctrl+K W | Cmd+K W |
| Zen mode | Ctrl+K Z | Cmd+K Z |
Multi-cursor and selection
Multi-cursor lets you edit in many places at once. Combine with column selection (Shift+Alt+Drag) for tabular edits and with Ctrl/Cmd+Shift+L to apply the same change to every match of the current selection.
// Before: 5 lines that need the same prefix added
apple
banana
cherry
date
elderberry
// Cmd+D across each word, then type `fruit_` to get:
fruit_apple
fruit_banana
fruit_cherry
fruit_date
fruit_elderberry
| Action | Windows / Linux | macOS |
|---|---|---|
| Add cursor above / below | Ctrl+Alt+↑/↓ | Cmd+Option+↑/↓ |
| Select all occurrences of current word | Ctrl+F2 | Cmd+F2 |
| Expand / shrink selection | Shift+Alt+→/← | Ctrl+Shift+Cmd+→/← |
| Move cursor to matching bracket | Ctrl+Shift+\ | Cmd+Shift+\ |
Snippets
Snippets are templates with tab stops, placeholders, and variables that expand from a prefix trigger. Define project-wide ones in .vscode/snippets.code-snippets and language-specific ones in the language's JSON file.
// .vscode/snippets.code-snippets
{
"Express handler": {
"prefix": "exh",
"body": [
"export const handler: RequestHandler = async (req, res) => {",
" $1",
"};",
"$0"
],
"description": "Express request handler"
}
}
| Tab stop | Behavior |
|---|---|
$1, $2, … | Cursor order |
${1:label} | Placeholder with default |
$0 | Final cursor position |
$TM_FILENAME | Variable expansion (filename, date, etc.) |
${1|a,b,c|} | Choice list |
settings.json essentials
settings.json is the source of truth for editor behavior — sync it via Settings Sync across machines. The two highest-impact settings are editor.formatOnSave and a configured default formatter.
// .vscode/settings.json
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false,
"editor.bracketPairColorization.enabled": true,
"files.autoSave": "onFocusChange",
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
| Key | What it controls |
|---|---|
editor.formatOnSave | Run formatter on save |
editor.tabSize | Tab width |
editor.minimap.enabled | Show the code minimap |
editor.stickyScroll.enabled | Pin class/function header while scrolling |
editor.bracketPairColorization.enabled | Color matching brackets |
files.autoSave | off, afterDelay, onFocusChange, onWindowChange |
files.exclude | Hide files from the explorer |
workbench.colorTheme | Active theme |
tasks.json and one-off commands
tasks.json defines shell commands that VS Code can run from the Command Palette or bind to a shortcut. Use the npm: or ^npm: script detection so package.json scripts become tasks automatically.
// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "npm",
"script": "build",
"problemMatcher": ["$tsc"],
"group": { "kind": "build", "isDefault": true }
},
{
"label": "test",
"type": "npm",
"script": "test",
"group": { "kind": "test", "isDefault": true },
"presentation": { "reveal": "always" }
},
{
"label": "lint --fix",
"type": "shell",
"command": "eslint . --fix",
"problemMatcher": ["$eslint-stylish"]
}
]
}
| Key | Purpose |
|---|---|
label | Name shown in the Command Palette |
type | shell (arbitrary command), npm (package.json script), process |
problemMatcher | Maps output to editor squigglies ($tsc, $eslint-stylish) |
group | Marks as build/test and makes it the default for that group |
presentation.reveal | always/silent/never panel behavior |
Run via Terminal → Run Task… or with the default build shortcut Ctrl/Cmd+Shift+B.
Integrated terminal
The integrated terminal multiplexes panes and shares keybindings with the editor. Split it, name panes, and reuse the active file path with ${file} in tasks.
| Action | Windows / Linux | macOS |
|---|---|---|
| Toggle terminal | Ctrl+` | Ctrl+` |
| New terminal | Ctrl+Shift+` | Cmd+Shift+` |
| Split terminal | Ctrl+Shift+5 | Cmd+Shift+5 |
| Kill terminal | Ctrl+Shift+Delete (when focused) | same |
| Scroll up / down | Ctrl+Shift+↑/↓ | Cmd+Shift+↑/↓ |
Configure the default shell with terminal.integrated.defaultProfile.linux/macos/windows in settings.json.
Recommended extensions
These ship as standard kit in most setups. Install per-project via .vscode/extensions.json so the team gets a consistent editor.
| Extension | Publisher | Purpose |
|---|---|---|
| ESLint | dbaeumer.vscode-eslint | Lint and auto-fix as you type |
| Prettier | esbenp.prettier-vscode | Opinionated formatter |
| GitLens | eamodio.gitlens | Inline git blame and history |
| Error Lens | Alexander | Inline error and warning annotations |
| Path Intellisense | christian-kohler.path-intellisense | Auto-complete filenames in strings |
| Docker | ms-azuretools.vscode-docker | Dockerfile and compose support |
| Thunder Client | rangav.vscode-thunder-client | REST client without leaving the editor |
| Remote - SSH | ms-vscode-remote.remote-ssh | Full IDE on a remote machine |
| EditorConfig | EditorConfig.EditorConfig | Honour .editorconfig files |
| Markdown All in One | yzhang.markdown-all-in-one | Markdown shortcuts and TOC |
// .vscode/extensions.json — workspace recommendations
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"eamodio.gitlens",
"EditorConfig.EditorConfig"
],
"unwantedRecommendations": []
}