Coding Hub  /  Reference

keyboard shortcuts

The ones worth memorising, in VS Code, the browser and the terminal. Learn five a week rather than all of them at once.

How to use this

Mac uses ⌘ where Windows and Linux use Ctrl. Where they differ, both are given.

01 The five to learn first

If you learn nothing else on this page, learn these. Each one replaces something you currently do with the mouse several times an hour.

Pick one, use it deliberately for a day even when the mouse would be faster, and it becomes automatic. Then pick the next.

start here
Windows / LinuxMacDoes
Ctrl+S⌘+SSave. Most “it did not change” bugs are an unsaved file.
Ctrl+/⌘+/Comment or uncomment the line
Ctrl+Z⌘+ZUndo. Shift as well to redo.
Ctrl+Shift+P⌘+Shift+PCommand palette — every command, searchable
Ctrl+`⌘+`Show or hide the terminal

VS Code

The editor you will spend the most hours in.

02 Moving around

Opening a file by name is the one that changes how you work: stop hunting the sidebar and just type three letters of the filename.

navigation
Windows / LinuxMacDoes
Ctrl+P⌘+POpen a file by typing part of its name
Ctrl+Shift+F⌘+Shift+FSearch every file in the project
Ctrl+GCtrl+GGo to a line number
Ctrl+Home⌘+↑Top of the file
Ctrl+←⌥+←Jump one word left
Ctrl+B⌘+BShow or hide the sidebar
Ctrl+TabCtrl+TabSwitch between open files

03 Editing

The line commands are the ones that feel like magic the first time. You will never select-cut-click-paste a line again.

editing
Windows / LinuxMacDoes
Alt+↑ / ↓⌥+↑ / ↓Move the line up or down
Shift+Alt+↓Shift+⌥+↓Duplicate the line
Ctrl+Shift+K⌘+Shift+KDelete the line
Ctrl+Enter⌘+EnterNew line below, from anywhere on the line
Ctrl+D⌘+DSelect the next copy of the word — press again for more
Alt+click⌥+clickPut a second cursor there. Type in both at once.
Shift+Alt+FShift+⌥+FReformat the file
F2F2Rename a variable everywhere at once

04 Multi-cursor, properly

The one worth practising deliberately. Ctrl+D selects the word your cursor is in; press it again and it adds the next occurrence, with a cursor on each.

Rename three variables, add a comma to ten lines, wrap five strings in quotes — all in one go. Press Esc to drop back to one cursor.

one Ctrl+D per line, then type once
Before:                        After:
  fern                           "fern",
  cactus                         "cactus",
  ivy                            "ivy",

Select the first word, Ctrl+D twice, then type the quotes.

Browser

For when the page is the thing you are debugging.

05 Devtools

F12 opens the browser's developer tools. The Console tab is where console.log output and JavaScript errors appear — check it before concluding that nothing happened.

browser
Windows / LinuxMacDoes
F12⌘+⌥+IOpen devtools
Ctrl+Shift+C⌘+⌥+CInspect — click an element to find its markup
Ctrl+Shift+J⌘+⌥+JStraight to the Console
Ctrl+R⌘+RReload
Ctrl+Shift+R⌘+Shift+RHard reload, ignoring the cache
Ctrl+F⌘+FFind on the page

Terminal

Mostly the same everywhere.

06 Terminal keys

These work in nearly every terminal, on every system, including the one inside VS Code.

terminal
KeyDoes
TabComplete the filename you are typing
↑ / ↓Walk back through your command history
Ctrl+CStop whatever is running
Ctrl+LClear the screen
Ctrl+A / Ctrl+EStart / end of the line
Ctrl+RSearch your history
Ctrl+DClose the terminal, or exit Python's REPL

Making your own

When a command has no shortcut.

07 Rebinding

Every command in VS Code can be bound to a key. Open the keyboard shortcuts editor with Ctrl+K then Ctrl+S, search for the command, and click the pencil.

If a shortcut on this page does nothing, something else has claimed it — an extension, or the operating system. The shortcuts editor shows the conflict.

searching the palette instead
Ctrl+Shift+P, then type a few letters of what you want:

  format      ->  Format Document
  reload      ->  Developer: Reload Window
  settings    ->  Preferences: Open User Settings (JSON)
  theme       ->  Preferences: Color Theme

The palette shows the shortcut beside each command, which is
how most people learn them.