logo

VS Code Cheatsheet

Note:

  • Ctrl is used for Windows/Linux.
  • Cmd (⌘) is used for macOS.
  • Alt is used for Windows/Linux.
  • Option (⌥) is used for macOS.
  • Many commands can be accessed via the Command Palette: Ctrl+Shift+P (Win/Linux) | Cmd+Shift+P (macOS).

General & Essential

Action Windows/Linux macOS
Show Command Palette Ctrl+Shift+P, F1 Cmd+Shift+P, F1
Quick Open, Go to File Ctrl+P Cmd+P
Show User Settings Ctrl+, Cmd+,
Show Keyboard Shortcuts Ctrl+K Ctrl+S Cmd+K Cmd+S
New Window/Instance Ctrl+Shift+N Cmd+Shift+N
Close Window/Instance Ctrl+Shift+W Cmd+Shift+W
Toggle Full Screen F11 Ctrl+Cmd+F
Toggle Zen Mode Ctrl+K Z Cmd+K Z

Basic Editing

Action Windows/Linux macOS
Cut line Ctrl+X Cmd+X
Copy line Ctrl+C Cmd+C
Paste Ctrl+V Cmd+V
Undo Ctrl+Z Cmd+Z
Redo Ctrl+Y / Ctrl+Shift+Z Cmd+Shift+Z
Select All Ctrl+A Cmd+A
Select Line Ctrl+L Cmd+L
Delete Line Ctrl+Shift+K Cmd+Shift+K
Insert Line Below Ctrl+Enter Cmd+Enter
Insert Line Above Ctrl+Shift+Enter Cmd+Shift+Enter
Move Line Up Alt+Up Arrow Option+Up Arrow
Move Line Down Alt+Down Arrow Option+Down Arrow
Duplicate Line Up Shift+Alt+Up Arrow Shift+Option+Up Arrow
Duplicate Line Down Shift+Alt+Down Arrow Shift+Option+Down Arrow
Indent Line Ctrl+] Cmd+]
Outdent Line Ctrl+[ Cmd+[
Go to Beginning of Line Home Cmd+Left Arrow, Home
Go to End of Line End Cmd+Right Arrow, End
Go to Beginning of File Ctrl+Home Cmd+Up Arrow, Cmd+Home
Go to End of File Ctrl+End Cmd+Down Arrow, Cmd+End

Code Editing & Formatting

Action Windows/Linux macOS
Toggle Line Comment Ctrl+/ Cmd+/
Toggle Block Comment Shift+Alt+A Shift+Option+A
Format Document Shift+Alt+F Shift+Option+F
Format Selection Ctrl+K Ctrl+F Cmd+K Cmd+F
Trigger Suggestion Ctrl+Space Ctrl+Space, Option+Esc
Trigger Parameter Hints Ctrl+Shift+Space Cmd+Shift+Space
Rename Symbol F2 F2
Quick Fix / Refactor Ctrl+. Cmd+.
Go to Definition F12, Ctrl+Click F12, Cmd+Click
Peek Definition Alt+F12 Option+F12
Go to References Shift+F12 Shift+F12

Navigation

Action Windows/Linux macOS
Go to Symbol in File... Ctrl+Shift+O Cmd+Shift+O
Go to Symbol in Workspace... Ctrl+T Cmd+T
Go to Line/Column... Ctrl+G Ctrl+G
Go Back (Cursor Position) Alt+Left Arrow Ctrl+- or Cmd+[
Go Forward (Cursor Position) Alt+Right Arrow Ctrl+Shift+- or Cmd+]
Switch Editor Tabs Ctrl+Tab, Ctrl+PageDown Ctrl+Tab, Cmd+Option+Right Arrow
Switch Editor Tabs (Reverse) Ctrl+Shift+Tab, Ctrl+PageUp Ctrl+Shift+Tab, Cmd+Option+Left Arrow
Go to Next Error/Warning F8 F8
Go to Previous Error/Warning Shift+F8 Shift+F8

Search & Replace

Action Windows/Linux macOS
Find Ctrl+F Cmd+F
Replace Ctrl+H Cmd+Option+F
Find Next F3 Cmd+G
Find Previous Shift+F3 Cmd+Shift+G
Select Next Find Match Ctrl+D Cmd+D
Select All Find Matches Ctrl+Shift+L Cmd+Shift+L
Find in Files Ctrl+Shift+F Cmd+Shift+F
Replace in Files Ctrl+Shift+H Cmd+Shift+H

Multi-Cursor & Selection

Action Windows/Linux macOS
Insert Cursor Above Ctrl+Alt+Up Arrow Cmd+Option+Up Arrow
Insert Cursor Below Ctrl+Alt+Down Arrow Cmd+Option+Down Arrow
Add Selection To Next Find Match Ctrl+D Cmd+D
Undo Last Cursor Operation Ctrl+U Cmd+U
Column (Box) Selection Shift+Alt+Mouse Drag Shift+Option+Mouse Drag
Column Select w/ Keyboard Ctrl+Shift+Alt+Arrows Cmd+Shift+Option+Arrows

File Management

Action Windows/Linux macOS
New File Ctrl+N Cmd+N
Open File... Ctrl+O Cmd+O
Save Ctrl+S Cmd+S
Save As... Ctrl+Shift+S Cmd+Shift+S
Save All Ctrl+K S Cmd+Option+S
Close Editor Ctrl+W, Ctrl+F4 Cmd+W
Reopen Closed Editor Ctrl+Shift+T Cmd+Shift+T
Show Explorer Ctrl+Shift+E Cmd+Shift+E
Reveal Active File Ctrl+K R Cmd+K R

Display & Window Management

Action Windows/Linux macOS
Toggle Sidebar Visibility Ctrl+B Cmd+B
Toggle Panel Visibility Ctrl+J Cmd+J
Split Editor Ctrl+\ Cmd+\
Focus into Editor Group 1/2/3 Ctrl+1/2/3 Cmd+1/2/3
Move Editor into Next Group Ctrl+K Ctrl+Right Arrow Cmd+K Cmd+Right Arrow
Move Editor into Prev Group Ctrl+K Ctrl+Left Arrow Cmd+K Cmd+Left Arrow

Integrated Terminal

Action Windows/Linux macOS
Show Integrated Terminal `Ctrl+`` (backtick) `Ctrl+`` (backtick)
Create New Terminal `Ctrl+Shift+`` `Cmd+Shift+``
Scroll Up/Down Ctrl+Up/Down Cmd+Up/Down
Scroll Page Up/Down Shift+PageUp/PageDown Shift+PageUp/PageDown
Clear Terminal Ctrl+K (often) or type clear Cmd+K or type clear

Debugging

Action Windows/Linux macOS
Toggle Breakpoint F9 F9
Start/Continue F5 F5
Stop Shift+F5 Shift+F5
Step Over F10 F10
Step Into F11 F11
Step Out Shift+F11 Shift+F11
Show Debug Console Ctrl+Shift+Y Cmd+Shift+Y

Command Pallete

Cmd + P or Ctrl + P: Open command pallete

  • >: commands
  • @ (or Cmd + Shift + .): scroll to symbol
  • # global symbol search
  • : (or Control + G): go to line

Frequently Used Shortcuts

  • Shift + left/right arrow: select text
  • option + left/right arrow: got to previous/next word
  • Cmd + D: select the word. Press multiple times to select multiple same word.
  • Cmd + L: select the line
  • option/Alt + click: set multiple cursors
  • option/Alt + up/down arrow: move the line up or down
  • option/ALt + Shift + up/down arrow: copy the line up or down
  • Cmd + /: toggle comment
  • option + shift + o: auto sort imports

FAQ

How to modify the key bindings?

You can customize almost all of these shortcuts via File > Preferences > Keyboard Shortcuts (Code > Preferences > Keyboard Shortcuts on macOS) or by opening the Command Palette (Ctrl+Shift+P | Cmd+Shift+P) and typing Keyboard Shortcuts.

How to start VS Code from the commandline?

From the commandline, open from the current location:

$ code .