VS Code shortcut keys start with one that leads to all the others: Ctrl + Shift + P opens the Command Palette, where you can type any action, such as format or toggle terminal, and see its key beside it. Ctrl + P jumps to any file by name, and Ctrl + ` opens the built in terminal.
To run code, press F5 to start with the debugger or Ctrl + F5 to run without it. Shift + Alt + F formats the whole file, fixing indentation and alignment. On a Mac, replace Ctrl with Command for most of these.
Quick facts
Command Palette
Ctrl + Shift + POpen file by name
Ctrl + PTerminal
Ctrl + `Run with debugger
F5Run without debugger
Ctrl + F5Format document
Shift + Alt + FToggle comment
Ctrl + /
VS Code shortcut keys for running code
| Keys | Action |
|---|---|
| F5 | Start debugging |
| Ctrl + F5 | Run without debugging |
| Shift + F5 | Stop |
| F9 | Toggle breakpoint |
| F10 | Step over |
| F11 | Step into |
| Ctrl + ` | Show or hide the terminal |
| Ctrl + Shift + ` | New terminal |
The shortcut key to run code in VS Code depends on the language setup. Python and JavaScript files run with Ctrl + F5 once the language extension is installed. Many students also add a popular code runner extension, which uses Ctrl + Alt + N to run the current file and show the output panel. Typing python file.py in the terminal always works as a fallback.
Line editing and multiple cursors
| Keys | Action |
|---|---|
| Alt + Up | Move line up |
| Alt + Down | Move line down |
| Shift + Alt + Down | Copy line down |
| Ctrl + Shift + K | Delete line |
| Ctrl + Enter | New line below |
| Ctrl + / | Toggle line comment |
| Ctrl + D | Select next match of the word |
| Ctrl + Shift + L | Select all matches |
| Alt + click | Add another cursor |
| Ctrl + Alt + Down | Add cursor on the line below |
Multiple cursors are the feature people miss most in other editors. Put the cursor on a variable name, press Ctrl + D a few times to select the next uses, and type the new name; every copy changes at once. For a safe rename across the whole project, use F2 on the name instead.
Visual Studio Code alignment shortcut key
Shift + Alt + F runs Format Document, which aligns indentation, spacing and brackets according to the language's formatter. Ctrl + K followed by Ctrl + F formats only the selection. Ctrl + ] and Ctrl + [ indent and outdent selected lines. Turn on Format On Save in Settings (Ctrl + ,) so every save tidies the file automatically.
Visual Studio shortcut keys
The full Visual Studio IDE, used for C# and C++ projects, shares the debugging keys: F5 debug, Ctrl + F5 run, F9 breakpoint and F10 or F11 to step. Building uses Ctrl + Shift + B. Formatting and comments use chords: Ctrl + K then Ctrl + D formats the document, Ctrl + K then Ctrl + C comments a selection and Ctrl + K then Ctrl + U removes the comment.
When a shortcut does not work
| Problem | Fix |
|---|---|
| Ctrl + ` does nothing | On some layouts the key differs; use View, Terminal |
| Another extension took the key | Open Keyboard Shortcuts with Ctrl + K, then Ctrl + S, and search it |
| Format Document does nothing | No formatter for that language is installed |
| Alt + arrows switch windows | Some laptop tools use them; change the tool's keys |
Frequently asked questions
What are the most useful VS Code shortcut keys?
Ctrl + Shift + P, Ctrl + P, Ctrl + ` and Shift + Alt + F.
What is the shortcut key to run code in VS Code?
How do I format code in VS Code?
How do I comment several lines?
Select them and press Ctrl + /.
How do I edit many lines at once?
Use Ctrl + D or Alt + click for multiple cursors.