Coding

VS Code Keyboard Shortcuts: The Useful Ones for Windows and Mac

The VS Code shortcut to learn first is the Command Palette, Ctrl+Shift+P on Windows and Linux or Cmd+Shift+P on macOS, because it finds every command and shows its shortcut next to the name. After that, Ctrl+P (go to file), Ctrl+D (select next match), Alt+Up/Down (move line) and Ctrl+/ (toggle comment) cover most daily editing.

All shortcuts below are VS Code's defaults, taken from Microsoft's official printable reference sheets. On macOS, Ctrl usually becomes Cmd, but not always, so the tables list both. If you have installed a keymap extension or changed bindings, yours may differ; the Keyboard Shortcuts editor (Ctrl+K Ctrl+S) shows what is actually active.

How to read the shortcuts

  • Ctrl+Shift+P means hold Ctrl and Shift, then press P.
  • Ctrl+K Ctrl+S is a chord: press Ctrl+K, let go, then press Ctrl+S.
  • On macOS, Option is the Alt key and Cmd is the Command key.

General and finding things

ActionWindows / LinuxmacOS
Command PaletteCtrl+Shift+P or F1Cmd+Shift+P or F1
Quick Open, go to fileCtrl+PCmd+P
Go to lineCtrl+GCtrl+G
Go to symbol in fileCtrl+Shift+OCmd+Shift+O
Show all symbolsCtrl+TCmd+T
SettingsCtrl+,Cmd+,
Keyboard Shortcuts editorCtrl+K Ctrl+SCmd+K Cmd+S
Find in file / ReplaceCtrl+F / Ctrl+HCmd+F / Option+Cmd+F
Search across filesCtrl+Shift+FCmd+Shift+F
Replace across filesCtrl+Shift+HCmd+Shift+H

In Quick Open, type ? to see the other things it can do besides opening files.

Line editing

ActionWindowsmacOS
Move line up / downAlt+Up / Alt+DownOption+Up / Option+Down
Copy line up / downShift+Alt+Up / Shift+Alt+DownShift+Option+Up / Shift+Option+Down
Delete lineCtrl+Shift+KCmd+Shift+K
Cut / copy whole line (nothing selected)Ctrl+X / Ctrl+CCmd+X / Cmd+C
Insert line below / aboveCtrl+Enter / Ctrl+Shift+EnterCmd+Enter / Cmd+Shift+Enter
Indent / outdent lineCtrl+] / Ctrl+[Cmd+] / Cmd+[
Toggle line commentCtrl+/Cmd+/
Toggle block commentShift+Alt+AShift+Option+A
Jump to matching bracketCtrl+Shift+\Cmd+Shift+\
Toggle word wrapAlt+ZOption+Z
Fold / unfold regionCtrl+Shift+[ / Ctrl+Shift+]Option+Cmd+[ / Option+Cmd+]

The "nothing selected" row is worth knowing: with no selection, Ctrl+C copies the entire current line and Ctrl+X cuts it.

Multi-cursor and selection

Multi-cursor editing is where VS Code saves the most time: rename a variable in five places at once, or add a comma to the end of 20 lines.

ActionWindowsmacOS
Add selection to next matchCtrl+DCmd+D
Select all occurrences of the selectionCtrl+Shift+LCmd+Shift+L
Insert cursor with the mouseAlt+ClickOption+Click
Insert cursor above / belowCtrl+Alt+Up / Ctrl+Alt+DownOption+Cmd+Up / Option+Cmd+Down
Cursor at end of each selected lineShift+Alt+IShift+Option+I
Undo last cursor operationCtrl+UCmd+U
Select current lineCtrl+LCmd+L
Expand / shrink selectionShift+Alt+Right / Shift+Alt+LeftCtrl+Shift+Cmd+Right / Left
Column (box) selectionShift+Alt + dragShift+Option + drag

A typical sequence: double-click a word, press Ctrl+D a few times to pick up the next matches (Ctrl+K Ctrl+D moves the last selection on to the following match, which skips one), then type to change them all. Press Esc to go back to a single cursor.

Code navigation and refactoring

ActionWindowsmacOS
Go to definitionF12F12
Peek definitionAlt+F12Option+F12
Show referencesShift+F12Shift+F12
Rename symbolF2F2
Quick FixCtrl+.Cmd+.
Trigger suggestionCtrl+SpaceCtrl+Space
Format documentShift+Alt+FShift+Option+F
Go back / forwardAlt+Left / Alt+RightCtrl+- / Ctrl+Shift+-
Next / previous errorF8 / Shift+F8F8 / Shift+F8
Problems panelCtrl+Shift+MCmd+Shift+M

Rename symbol (F2) renames the symbol itself rather than matching text, so it is the tool for renaming variables and functions; find-and-replace also hits comments and unrelated words with the same spelling.

Editors, panels and the terminal

ActionWindowsmacOS
Show integrated terminalCtrl+`Ctrl+`
New terminalCtrl+Shift+`Ctrl+Shift+`
Toggle sidebarCtrl+BCmd+B
ExplorerCtrl+Shift+ECmd+Shift+E
Source ControlCtrl+Shift+GCtrl+Shift+G
ExtensionsCtrl+Shift+XCmd+Shift+X
Split editorCtrl+\Cmd+\
Focus editor group 1 / 2 / 3Ctrl+1 / 2 / 3Cmd+1 / 2 / 3
Close editorCtrl+F4 or Ctrl+WCmd+W
Reopen closed editorCtrl+Shift+TCmd+Shift+T
Save allCtrl+K SOption+Cmd+S
Zen ModeCtrl+K Z (Esc Esc to exit)Cmd+K Z
Markdown preview to the sideCtrl+K VCmd+K V

Debugging uses the function keys on every platform: F9 toggles a breakpoint, F5 starts or continues, F10 steps over, F11 steps into and Shift+F11 steps out, and Shift+F5 stops.

Linux differences

Linux mostly matches Windows, but Microsoft's Linux sheet lists a few different defaults:

ActionWindowsLinux
Format documentShift+Alt+FCtrl+Shift+I
Insert cursor above / belowCtrl+Alt+Up/DownShift+Alt+Up/Down
Toggle block commentShift+Alt+ACtrl+Shift+A
Go back / forwardAlt+Left/RightCtrl+Alt+- / Ctrl+Shift+-
Copy / paste in the terminalCtrl+C / Ctrl+VCtrl+Shift+C / Ctrl+Shift+V
Close windowCtrl+Shift+WCtrl+W

The Linux sheet also notes that the Alt+Click gesture may not work on some distributions. You can switch the multi-cursor modifier to Ctrl+Click with the editor.multiCursorModifier setting.

Change or add a shortcut

  1. Open the Keyboard Shortcuts editor with Ctrl+K Ctrl+S (Cmd+K Cmd+S), or File > Preferences > Keyboard Shortcuts.
  2. Search for the command, double-click it, press the keys you want, then Enter.
  3. To check for clashes, right-click the entry and choose Show Same Keybindings.

For more control, the Open Keyboard Shortcuts (JSON) button in the editor's title bar opens keybindings.json, where each rule has a key, a command and an optional when condition:

[
  { "key": "ctrl+shift+d", "command": "editor.action.copyLinesDownAction",
    "when": "editorTextFocus && !editorReadonly" },
  { "key": "tab", "command": "-jumpToNextSnippetPlaceholder" }
]

The first rule binds a new key to "copy line down" only while you are typing in an editable file. The second shows the documented way to remove a default binding: a minus sign before the command name. If a shortcut does nothing, run Developer: Toggle Keyboard Shortcuts Troubleshooting from the Command Palette; the Output panel then logs which keys VS Code received and which command, if any, they triggered.

If you pair these shortcuts with an AI assistant in the editor, how to use AI for coding covers a workflow that keeps you in control of the changes.

Frequently asked questions

How do I see all VS Code keyboard shortcuts?
Open the Keyboard Shortcuts editor with Ctrl+K Ctrl+S on Windows and Linux or Cmd+K Cmd+S on macOS, or select File > Preferences > Keyboard Shortcuts. It lists every command with its current binding and lets you search by command name or by pressing the keys. Help > Keyboard Shortcut Reference opens Microsoft's printable PDF for your platform.
Why doesn't a VS Code shortcut work?
Usually another binding or an extension has taken the same keys, or the shortcut only applies in a certain context, such as when the editor has focus. Right-click the entry in the Keyboard Shortcuts editor and choose Show Same Keybindings to find conflicts, or run Developer: Toggle Keyboard Shortcuts Troubleshooting from the Command Palette to log which command each key press triggers.
How do I reset or remove a VS Code shortcut?
In the Keyboard Shortcuts editor, right-click the entry and choose Remove Keybinding, or reset it to the default from the same menu. In keybindings.json, you remove a default binding by adding a rule with a minus sign before the command name, for example { "key": "tab", "command": "-jumpToNextSnippetPlaceholder" }.
What does Ctrl+K Ctrl+S mean?
It is a chord: press Ctrl+K, release, then press Ctrl+S. VS Code waits for the second key after the first. Many VS Code shortcuts start with Ctrl+K (Cmd+K on macOS) in this way, such as Ctrl+K Ctrl+C to add a line comment.

Sources