Basics
Introduction
Shortcuts below are the macOS defaults. On Windows and Linux, replace ⌘ with
Ctrl and ⌥ with Alt.
- Keyboard shortcuts (code.visualstudio.com)
- Command line interface (code.visualstudio.com)
Command palette
| Key | Description |
|---|---|
⇧⌘P | Show all commands |
⌘P | Quick open file |
⌘T | Go to symbol in workspace |
⇧⌘O | Go to symbol in file |
⌃G | Go to line |
⌘K ⌘S | Keyboard shortcuts |
See: Keyboard shortcuts
Files
| Key | Description |
|---|---|
⌘N | New file |
⌘O | Open file |
⌘S | Save |
⇧⌘S | Save as |
⌥⌘S | Save all |
⌘W | Close editor |
⌘K ⌘W | Close all editors |
⇧⌘T | Reopen closed editor |
⌘K P | Copy path of active file |
⌘K R | Reveal active file |
See: User interface
Editing
| Key | Description |
|---|---|
⌘C / ⌘X | Copy/cut line (no selection) |
⌥Up / ⌥Down | Move line up/down |
⇧⌥Up / ⇧⌥Down | Copy line up/down |
⇧⌘K | Delete line |
⌘Enter / ⇧⌘Enter | Insert line below/above |
⌘] / ⌘[ | Indent/outdent line |
⌘/ | Toggle line comment |
⇧⌥A | Toggle block comment |
⇧⌥F | Format document |
⌘K ⌘F | Format selection |
⌘K ⌘X | Trim trailing whitespace |
⌥Z | Toggle word wrap |
See: Code basics
Multi-cursor
| Key | Description |
|---|---|
⌥ + click | Insert cursor |
⌥⌘Up / ⌥⌘Down | Insert cursor above/below |
⌘D | Add next find match to selection |
⌘K ⌘D | Skip last match |
⇧⌘L | Select all occurrences |
⌘F2 | Select all occurrences of word |
⌘U | Undo last cursor operation |
⇧⌥I | Cursor at end of each line |
⌃⇧⌘Right / ⌃⇧⌘Left | Expand/shrink selection |
See: Multiple selections
Search
Find
| Key | Description |
|---|---|
⌘F | Find |
⌥⌘F | Replace |
⌘G | Find next match |
⇧⌘G | Find previous match |
⌥Enter | Select all matches |
See: Search and replace
Search across files
| Key | Description |
|---|---|
⇧⌘F | Find in files |
⇧⌘H | Replace in files |
⇧⌘J | Toggle search details |
See: Search across files
Views
Sidebar
| Key | Description |
|---|---|
⌘B | Toggle sidebar |
⇧⌘E | Explorer |
⇧⌘F | Search |
⌃⇧G | Source control |
⇧⌘D | Debug |
⇧⌘X | Extensions |
See: User interface
Panel
| Key | Description |
|---|---|
⌘J | Toggle panel |
⇧⌘M | Problems |
⇧⌘U | Output |
⇧⌘Y | Debug console |
⌃` | Terminal |
⌃⇧` | New terminal |
See: Terminal basics
Zen mode
| Key | Description |
|---|---|
⌘K Z | Toggle zen mode |
Esc Esc | Exit zen mode |
⌃⌘F | Toggle full screen |
⌥⌘0 | Toggle editor layout |
⌘= / ⇧⌘- | Zoom in/out |
See: Custom layout
Navigation
Code navigation
| Key | Description |
|---|---|
F12 | Go to definition |
⌥F12 | Peek definition |
⌘K F12 | Open definition to the side |
⇧F12 | Show references |
F2 | Rename symbol |
⌘. | Quick fix |
⌃Space | Trigger suggestions |
⇧⌘Space | Parameter hints |
⌘K ⌘I | Show hover |
F8 / ⇧F8 | Next/previous problem |
⌃- / ⌃⇧- | Go back/forward |
See: Code navigation
Editor groups
| Key | Description |
|---|---|
⌘\ | Split editor |
⌘1 / ⌘2 / ⌘3 | Focus editor group |
⌘K ⌘Left / ⌘K ⌘Right | Focus previous/next group |
⌃Tab / ⌃⇧Tab | Next/previous editor |
⌘K Enter | Keep preview editor open |
See: Custom layout
Debug
Starting and stopping
| Key | Description |
|---|---|
F5 | Start/continue |
⇧⌘F5 | Restart |
⇧F5 | Stop |
⌃F5 | Start without debugging |
See: Debugging
Breakpoints and stepping
| Key | Description |
|---|---|
F9 | Toggle breakpoint |
F10 | Step over |
F11 / ⇧F11 | Step into/out |
⇧⌘D | Debug view |
⇧⌘Y | Debug 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
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
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
- Keyboard shortcuts (macOS) (code.visualstudio.com)
- Keyboard shortcuts (Windows) (code.visualstudio.com)
- Keyboard shortcuts (Linux) (code.visualstudio.com)
- Release notes (code.visualstudio.com)
0 Comments for this cheatsheet. Write yours!