Command Palette
The Command Palette (Ctrl+Shift+P / Cmd+Shift+P) runs any editor command, extension action, or workspace task by name — faster than chasing menus, faster than remembering keybindings, and discoverable.
Modes, commands, tasks, extensions
EXAMPLE
// 1) Open the palette
// Ctrl+Shift+P (Cmd+Shift+P on macOS)
// F1 — same thing
//
// Start typing; matched commands narrow live. Enter runs the highlighted command.
// 2) Palette modes — the leading character changes scope
//
// (no prefix) — commands
// > — commands (explicit; auto-set when opened with Ctrl+Shift+P)
// ? — what does each prefix do (help)
// no prefix — file picker (same as Ctrl+P)
// @ — symbol search in the active file
// @: — symbols grouped by category in the active file
// # — symbol search across the workspace (same as Ctrl+T)
// : — go to line (e.g. :120)
// :L,COL — go to line:col (e.g. :120:8)
// ! — error / warning picker
// ~ — recently-opened workspaces
// * — view picker (open Output, Problems, Debug Console …)
// 3) High-value commands by category
//
// Editing:
// Format Document
// Format Selection
// Organize Imports
// Sort Lines Ascending / Descending
// Trim Trailing Whitespace
// Toggle Word Wrap
// Change Language Mode
// Convert Indentation to Spaces / Tabs
//
// Navigation:
// Go to File… (Ctrl+P)
// Go to Symbol in Workspace… (#)
// Go to Definition (F12)
// Find All References (Shift+F12)
// Open Previous / Next Editor
// Switch to Tab N
//
// Search / replace:
// Search: Find in Files
// Search: Replace in Files
// Search: Toggle Regex / Case Sensitive / Whole Word
// Search: Toggle Search Details
//
// Workspaces:
// File: Open Folder…
// Workspaces: Add Folder to Workspace…
// Preferences: Open User / Workspace Settings
// Preferences: Open User Settings (JSON)
// Preferences: Open Keyboard Shortcuts (JSON)
//
// Terminal:
// Terminal: Create New Integrated Terminal
// Terminal: Split Terminal
// Terminal: Rename
// Terminal: Run Selected Text in Active Terminal
//
// Git:
// Git: Stage All Changes
// Git: Commit
// Git: Push
// Git: Pull
// Git: Checkout to…
// GitHub Pull Requests: Create PR (with the GH extension)
//
// Extensions:
// Extensions: Install Extensions…
// Extensions: Disable
// Extensions: Install from VSIX
// 4) Tasks — run npm / make / build commands from the palette
// .vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: dev",
"type": "npm",
"script": "dev",
"isBackground": true,
"problemMatcher": ["$tsc-watch"]
},
{
"label": "format + lint",
"type": "shell",
"command": "npm run format && npm run lint -- --fix",
"presentation": { "clear": true, "reveal": "silent" }
}
]
}
//
// Then: 'Tasks: Run Task' → pick → runs in the integrated terminal.
// Set 'group': 'build' on the main task and use 'Tasks: Run Build Task' (Ctrl+Shift+B) instead.
// 5) Launch debugging from the palette
// Debug: Start Debugging (F5)
// Debug: Add Configuration
// Debug: Toggle Breakpoint (F9)
// Debug: Step Over / Into / Out
//
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "vitest current file",
"program": "${workspaceFolder}/node_modules/vitest/vitest.mjs",
"args": ["run", "--no-coverage", "${file}"],
"console": "integratedTerminal"
}
]
}
// 6) Snippets — custom commands you can fire from the palette by name
// Configure User Snippets → snippets/global.code-snippets
{
"console.log highlighted": {
"scope": "javascript,typescript",
"prefix": "cll",
"body": ["console.log('%s →', '$TM_SELECTED_TEXT', $TM_SELECTED_TEXT);"],
"description": "console.log a highlighted symbol"
}
}
// 7) Run extensions from the palette
// Extensions ADD commands. After installing, search for the extension name in the palette
// to see everything it offers. Try:
// Path Intellisense
// Project Manager — quickly switch projects
// Multi-root sample — view registered tasks
// Error Lens — inline error rendering toggle
// GitLens — Git Blame Toggle, Git Compare
// 8) Custom commands via keybindings.json
// Add your own palette entries via keybindings + 'workbench.action.terminal.sendSequence'.
[
{
"key": "ctrl+alt+t",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "npm run test:watch\u000D" }
}
]
//
// Now 'Run Terminal Command' style flows have a hotkey.
// 9) Less-known but very useful
// Developer: Reload Window — clears stuck extensions without restart
// Developer: Toggle Developer Tools — Chrome devtools inside VS Code
// Editor: Show Hover — open the hover popover at cursor
// View: Toggle Word Wrap
// View: Toggle Sticky Scroll
// View: Toggle Minimap
// Help: Show All Commands — back to the palette itself
// 10) Workspace trust
// Workspaces: Manage Workspace Trust
// Untrusted workspaces disable tasks and many extension commands by design.
// If commands are mysteriously missing, check the trust banner.
// 11) Settings & shortcuts (the palette opens these)
// Preferences: Open Settings (UI)
// Preferences: Open Settings (JSON)
// Preferences: Open Workspace Settings
// Preferences: Open Default Settings (JSON) — read-only reference
// Preferences: Open Keyboard Shortcuts
//
// Tip: Settings UI has a Modify-in-settings.json link on every row — palette → that command.
// 12) Tips
// • Recently-run commands appear at the top — your daily workflow gets faster over time
// • Pin a command (mouse over → pin icon) to keep it visible
// • Many commands accept arguments via keybindings.json's 'args' field for power workflows
// • The palette can run ANY extension or built-in command — discoverability beats memorising hotkeys
//
// 13) Common bugs / friction
// • Command 'not found' — the responsible extension is disabled or the workspace isn't trusted
// • Task fails silently — open the Output panel ('*' picker → 'Tasks')
// • Cmd ran twice — keybinding + command both wired; pick one
// • Path Intellisense / TS server not responding — Developer: Reload Window often fixes it
// • Search includes node_modules → check 'search.exclude' settings
Why it matters
The Command Palette is VS Code’s single most powerful surface — learn the prefix modes (>, @, #, :, !) and you almost never need a menu or keyboard shortcut you didn’t pick yourself. Configure tasks.json and launch.json so build, lint, and debug commands all show up there too.
Tip: Tweak the snippet with Try it Yourself », then sit the quiz at the bottom of the page.
Example
Example
// Ctrl/Cmd + Shift + P opens the Command Palette. // Prefixes: // > command (default) // : go to line // @ go to symbol in file // # go to symbol in workspace // ? show helpTry it Yourself »
Exercise
Open the Command Palette (Win/Linux).
Ctrl + Shift +
One letter.
Discussion
Loading…