VS Code keyboard shortcuts
Visual Studio Code is the free code editor that most beginners now start with. It can be driven almost entirely from the keyboard. The first column is for Windows and Linux, the second for the Mac.
The two that unlock everything
Ctrl + Shift + P opens the Command Palette. Type a few letters of what you want, such as "format" or "terminal" or "theme", and every matching command appears, with its own shortcut shown beside it. You never need to remember where something is in the menus.
Ctrl + P opens Quick Open. Type part of a file name and press Enter to open it. In a project of hundreds of files, it is far quicker than the file tree.
The next eight
- Ctrl + / turns the current line into a comment, and back.
- Alt + Up arrow and Alt + Down arrow move the line up or down.
- Shift + Alt + Down arrow copies the line below itself.
- Ctrl + D selects the next occurrence of the selected word, for editing several at once.
- Ctrl + ` opens the built-in terminal.
- Ctrl + B shows or hides the side bar.
- Shift + Alt + F formats the whole file.
- F2 renames a variable or function everywhere it is used.
| Windows | Mac | What it does |
|---|---|---|
| Ctrl + Shift + P or F1 | Cmd + Shift + P or F1 | Open the Command Palette |
| Ctrl + P | Cmd + P | Quick Open: go to a file by name |
| Ctrl + , | Cmd + , | Open Settings |
| Ctrl + K then Ctrl + S | Cmd + K then Cmd + S | Open the list of keyboard shortcuts |
| Ctrl + B | Cmd + B | Show or hide the side bar |
| Ctrl + ` | Ctrl + ` | Show or hide the terminal |
| Ctrl + Shift + E | Cmd + Shift + E | Show the Explorer (files) |
| Ctrl + Shift + F | Cmd + Shift + F | Search across all files |
| Ctrl + Shift + X | Cmd + Shift + X | Show Extensions |
| Ctrl + Shift + G | Ctrl + Shift + G | Show Source Control |
| Windows | Mac | What it does |
|---|---|---|
| Ctrl + N | Cmd + N | New file |
| Ctrl + O | Cmd + O | Open a file |
| Ctrl + S | Cmd + S | Save |
| Ctrl + Shift + S | Cmd + Shift + S | Save As |
| Ctrl + W | Cmd + W | Close the editor tab |
| Ctrl + Shift + T | Cmd + Shift + T | Reopen the closed editor |
| Ctrl + Tab | Ctrl + Tab | Switch between open files |
| Ctrl + \ | Cmd + \ | Split the editor in two |
| Ctrl + 1, 2, 3 | Cmd + 1, 2, 3 | Move to the first, second or third editor group |
| Windows | Mac | What it does |
|---|---|---|
| Ctrl + X | Cmd + X | Cut the whole line, when nothing is selected |
| Ctrl + C | Cmd + C | Copy the whole line, when nothing is selected |
| Alt + Up arrow or Alt + Down arrow | Option + Up arrow or Option + Down arrow | Move the line up or down |
| Shift + Alt + Up arrow or Shift + Alt + Down arrow | Shift + Option + Up arrow or Shift + Option + Down arrow | Copy the line up or down |
| Ctrl + Shift + K | Cmd + Shift + K | Delete the line |
| Ctrl + Enter | Cmd + Enter | Insert a line below |
| Ctrl + Shift + Enter | Cmd + Shift + Enter | Insert a line above |
| Ctrl + / | Cmd + / | Comment or uncomment the line |
| Shift + Alt + A | Shift + Option + A | Comment or uncomment a block |
| Ctrl + ] | Cmd + ] | Indent the line |
| Ctrl + [ | Cmd + [ | Outdent the line |
| Shift + Alt + F | Shift + Option + F | Format the document |
| Alt + Z | Option + Z | Word wrap on or off |
| Windows | Mac | What it does |
|---|---|---|
| Ctrl + D | Cmd + D | Add the next occurrence of the selection |
| Ctrl + Shift + L | Cmd + Shift + L | Select every occurrence of the selection |
| Alt + click | Option + click | Add a cursor where you click |
| Ctrl + Alt + Up arrow or Ctrl + Alt + Down arrow | Cmd + Option + Up arrow or Cmd + Option + Down arrow | Add a cursor on the line above or below |
| Ctrl + L | Cmd + L | Select the current line |
| Shift + Alt + Right arrow | Ctrl + Shift + Cmd + Right arrow | Expand the selection |
| Esc | Esc | Go back to a single cursor |
| Windows | Mac | What it does |
|---|---|---|
| Ctrl + F | Cmd + F | Find in the file |
| Ctrl + H | Cmd + Option + F | Replace in the file |
| Ctrl + G | Ctrl + G | Go to a line number |
| Ctrl + Shift + O | Cmd + Shift + O | Go to a symbol in the file |
| F12 | F12 | Go to the definition |
| Alt + Left arrow | Ctrl + - | Go back to where you were |
| F2 | F2 | Rename a symbol everywhere |
| Ctrl + Space | Ctrl + Space | Show suggestions |
| Ctrl + . | Cmd + . | Show quick fixes |
| F8 | F8 | Go to the next problem |
| Windows | Mac | What it does |
|---|---|---|
| F5 | F5 | Start or continue debugging |
| Ctrl + F5 | Ctrl + F5 | Run without debugging |
| Shift + F5 | Shift + F5 | Stop |
| F9 | F9 | Add or remove a breakpoint |
| F10 | F10 | Step over |
| F11 | F11 | Step into |
Editing several places at once
Multiple cursors are the feature that most changes how fast you edit. Put the cursor on a word and press Ctrl + D. The word is selected. Press Ctrl + D again and the next occurrence is selected too. Type, and both change together. It is a quick, visible way to rename something in a small area, and safer than find and replace because you see each one being added.
Line shortcuts need no selection
Ctrl + X, Ctrl + C and the Alt + arrow keys act on the whole line when nothing is selected. To move three lines, select any part of all three and press Alt + Up arrow.
Shortcuts can be changed, and extensions add more
Ctrl + K followed by Ctrl + S opens a searchable list of every shortcut, where any of them can be changed. Extensions add their own. If a shortcut here does something else on your computer, look it up in that list. People who come from another editor can install a keymap extension that brings its shortcuts along.
A printable sheet from the makers
In VS Code, Help, Keyboard Shortcuts Reference opens the official one-page sheet for your operating system.
This is an independent reference site. It is not connected with Microsoft, Apple, Google or any other maker of the programs named here. Product names belong to their owners and are used only to say where a shortcut works. Programs change; if a shortcut does not work for you, check the program's own help.