Basics

Introduction

Shortcuts below are the macOS defaults. On Windows and Linux, replace ⌘ with Ctrl and ⌥ with Alt.

Command palette

KeyDescription
⇧⌘PShow all commands
⌘PQuick open file
⌘TGo to symbol in workspace
⇧⌘OGo to symbol in file
⌃GGo to line
⌘K ⌘SKeyboard shortcuts

See: Keyboard shortcuts

Files

KeyDescription
⌘NNew file
⌘OOpen file
⌘SSave
⇧⌘SSave as
⌥⌘SSave all
⌘WClose editor
⌘K ⌘WClose all editors
⇧⌘TReopen closed editor
⌘K PCopy path of active file
⌘K RReveal active file

See: User interface

Editing

KeyDescription
⌘C / ⌘XCopy/cut line (no selection)
⌥Up / ⌥DownMove line up/down
⇧⌥Up / ⇧⌥DownCopy line up/down
⇧⌘KDelete line
⌘Enter / ⇧⌘EnterInsert line below/above
⌘] / ⌘[Indent/outdent line
⌘/Toggle line comment
⇧⌥AToggle block comment
⇧⌥FFormat document
⌘K ⌘FFormat selection
⌘K ⌘XTrim trailing whitespace
⌥ZToggle word wrap

See: Code basics

Multi-cursor

KeyDescription
⌥ + clickInsert cursor
⌥⌘Up / ⌥⌘DownInsert cursor above/below
⌘DAdd next find match to selection
⌘K ⌘DSkip last match
⇧⌘LSelect all occurrences
⌘F2Select all occurrences of word
⌘UUndo last cursor operation
⇧⌥ICursor at end of each line
⌃⇧⌘Right / ⌃⇧⌘LeftExpand/shrink selection

See: Multiple selections

Find

KeyDescription
⌘FFind
⌥⌘FReplace
⌘GFind next match
⇧⌘GFind previous match
⌥EnterSelect all matches

See: Search and replace

Search across files

KeyDescription
⇧⌘FFind in files
⇧⌘HReplace in files
⇧⌘JToggle search details

See: Search across files

Views

KeyDescription
⌘BToggle sidebar
⇧⌘EExplorer
⇧⌘FSearch
⌃⇧GSource control
⇧⌘DDebug
⇧⌘XExtensions

See: User interface

Panel

KeyDescription
⌘JToggle panel
⇧⌘MProblems
⇧⌘UOutput
⇧⌘YDebug console
⌃`Terminal
⌃⇧`New terminal

See: Terminal basics

Zen mode

KeyDescription
⌘K ZToggle zen mode
Esc EscExit zen mode
⌃⌘FToggle full screen
⌥⌘0Toggle editor layout
⌘= / ⇧⌘-Zoom in/out

See: Custom layout

Code navigation

KeyDescription
F12Go to definition
⌥F12Peek definition
⌘K F12Open definition to the side
⇧F12Show references
F2Rename symbol
⌘.Quick fix
⌃SpaceTrigger suggestions
⇧⌘SpaceParameter hints
⌘K ⌘IShow hover
F8 / ⇧F8Next/previous problem
⌃- / ⌃⇧-Go back/forward

See: Code navigation

Editor groups

KeyDescription
⌘\Split editor
⌘1 / ⌘2 / ⌘3Focus editor group
⌘K ⌘Left / ⌘K ⌘RightFocus previous/next group
⌃Tab / ⌃⇧TabNext/previous editor
⌘K EnterKeep preview editor open

See: Custom layout

Debug

Starting and stopping

KeyDescription
F5Start/continue
⇧⌘F5Restart
⇧F5Stop
⌃F5Start without debugging

See: Debugging

Breakpoints and stepping

KeyDescription
F9Toggle breakpoint
F10Step over
F11 / ⇧F11Step into/out
⇧⌘DDebug view
⇧⌘YDebug console

See: Debug actions

Command line

Opening files

code .                    # open current folder
code -g src/app.ts:42     # open at line 42
code --diff old.ts new.ts # diff two files
code --wait package.json  # wait until closed

See: Command line interface

Extensions

code --install-extension dbaeumer.vscode-eslint
code --list-extensions --show-versions
code --uninstall-extension dbaeumer.vscode-eslint
code --profile "Web" .    # open with a profile

See: Extension marketplace

Remote tunnels

code tunnel            # serve this machine
code tunnel --no-sleep # keep the host awake

Reachable from a browser or another VS Code client.

See: Remote tunnels

Settings

settings.json

{
  "editor.formatOnSave": true,
  "editor.rulers": [80],
  "files.autoSave": "onFocusChange",
  "editor.wordWrap": "on"
}

User settings live in ~/Library/Application Support/Code/User/settings.json on macOS, .vscode/settings.json for a workspace. ⌘, opens the settings UI.

See: Settings

keybindings.json

{
  "key": "ctrl+alt+t",
  "command": "workbench.action.terminal.new",
  "when": "editorTextFocus"
}

The Keyboard Shortcuts editor's title bar opens keybindings.json; entries there override the defaults.

See: Keybindings

References

0 Comments for this cheatsheet. Write yours!