VS Code Cheat Sheet

Visual Studio Code reference: command palette, keyboard shortcuts, multi-cursor, snippets, settings.json, tasks.json, terminal, and extensions.

Editors & Tools
vscode
editor
ide

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.

Table
ActionWindows / LinuxmacOS
Open Command PaletteCtrl+Shift+PCmd+Shift+P
Quick Open fileCtrl+PCmd+P
Go to symbol in fileCtrl+Shift+OCmd+Shift+O
Go to symbol in workspaceCtrl+TCmd+T
Open recentCtrl+RCmd+Shift+P then Recent
Toggle terminalCtrl+`Ctrl+`
Toggle sidebarCtrl+BCmd+B
Toggle panelCtrl+JCmd+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.

Table
ActionWindows / LinuxmacOS
Multi-cursor: next matchCtrl+DCmd+D
Multi-cursor: skip matchCtrl+K Ctrl+DCmd+K Cmd+D
Select all matchesCtrl+Shift+LCmd+Shift+L
Insert cursor at clickAlt+ClickOption+Click
Column selectionShift+Alt+DragShift+Option+Drag
Move line up / downAlt+↑ / Alt+↓Option+↑ / Option+↓
Copy line up / downShift+Alt+↑ / Shift+Alt+↓Shift+Option+↑ / Shift+Option+↓
Toggle line commentCtrl+/Cmd+/
Toggle block commentShift+Alt+AShift+Option+A
Go to definitionF12F12
Peek definitionAlt+F12Option+F12
Rename symbolF2F2
Format documentShift+Alt+FShift+Option+F
Format selectionCtrl+K Ctrl+FCmd+K Cmd+F
Split editorCtrl+\Cmd+\
Move editor groupCtrl+K ←/→Cmd+K ←/→
Close all editors in groupCtrl+K WCmd+K W
Zen modeCtrl+K ZCmd+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.

ts
// 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
Table
ActionWindows / LinuxmacOS
Add cursor above / belowCtrl+Alt+↑/↓Cmd+Option+↑/↓
Select all occurrences of current wordCtrl+F2Cmd+F2
Expand / shrink selectionShift+Alt+→/←Ctrl+Shift+Cmd+→/←
Move cursor to matching bracketCtrl+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.

jsonc
// .vscode/snippets.code-snippets
{
  "Express handler": {
    "prefix": "exh",
    "body": [
      "export const handler: RequestHandler = async (req, res) => {",
      "  $1",
      "};",
      "$0"
    ],
    "description": "Express request handler"
  }
}
Table
Tab stopBehavior
$1, $2, …Cursor order
${1:label}Placeholder with default
$0Final cursor position
$TM_FILENAMEVariable 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.

jsonc
// .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"
  }
}
Table
KeyWhat it controls
editor.formatOnSaveRun formatter on save
editor.tabSizeTab width
editor.minimap.enabledShow the code minimap
editor.stickyScroll.enabledPin class/function header while scrolling
editor.bracketPairColorization.enabledColor matching brackets
files.autoSaveoff, afterDelay, onFocusChange, onWindowChange
files.excludeHide files from the explorer
workbench.colorThemeActive 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.

jsonc
// .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"]
    }
  ]
}
Table
KeyPurpose
labelName shown in the Command Palette
typeshell (arbitrary command), npm (package.json script), process
problemMatcherMaps output to editor squigglies ($tsc, $eslint-stylish)
groupMarks as build/test and makes it the default for that group
presentation.revealalways/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.

Table
ActionWindows / LinuxmacOS
Toggle terminalCtrl+`Ctrl+`
New terminalCtrl+Shift+`Cmd+Shift+`
Split terminalCtrl+Shift+5Cmd+Shift+5
Kill terminalCtrl+Shift+Delete (when focused)same
Scroll up / downCtrl+Shift+↑/↓Cmd+Shift+↑/↓

Configure the default shell with terminal.integrated.defaultProfile.linux/macos/windows in settings.json.

References