VSCode Keyboard Shortcuts
VSCode has a lot of keyboard shortcuts to make your life easier. A lot. Perhaps you have consulted VSCode's own documentation for keyboard shortcuts on both MacOs and Windows. If you have looked at these documents, then you are likely not alone in what you may be feeling: how does this make my life easier? Which shortcuts are actually useful? How can I get up and running quickly with some useful shortcuts as well as test my memory of what shortcuts I think I know? This "guide" attempts to address some of these questions.
Getting Started
I have created two markdown files, one for MacOS and one for Windows, which essentially convert the PDFs linked to above into a "memory testing game" of sorts. You can click on either of these links to immediately get started (or keep reading for more info).
Sample Usage
Suppose you need to remember how to quickly copy a line(s) down or up. Then the following is how you could test your memory:
In MacOS
Copy line down/up
If you know the correct keystrokes to accomplish the above effect in MacOS, then good for you! If not, click the triangle to reveal the desired keystrokes: ⇧⌥↓ / ⇧⌥↑
Similarly, we have the following for Windows:
In Windows
Copy line down/up
Desired keystrokes (click the dropdown triangle to test or refresh your memory): Shift+Alt + ↓ / ↑
Demo of Copying a Line Up/Down
Watch the following demo to see "copy line down" in action and how it might make your life easier. (The keystrokes used to accomplish this are highlighted to the right.)
Frequently Used Shortcuts
If you like what you saw above, then you may want to check out some of my own frequently used shortcuts listed below.
Editing Shortcuts
Effect | MacOS | Windows |
---|---|---|
Copy line down/up | Click for keystrokes⇧⌥↓ / ⇧⌥↑ | Click for keystrokesShift+Alt + ↓ / ↑ |
Move line down/up | Click for keystrokes⌥↓ / ⌥↑ | Click for keystrokesAlt+ ↑ / ↓ |
Delete line | Click for keystrokes⇧⌘K | Click for keystrokesCtrl+Shift+K |
Indent/outdent line | Click for keystrokes⌘] / ⌘[ | Click for keystrokesCtrl+] / [ |
Go to beginning/end of line | Click for keystrokes←⌘ / ⌘→ | Click for keystrokesHome / End |
Go to beginning/end of file | Click for keystrokes⌘↑ / ⌘↓ | Click for keystrokesCtrl+Home / Ctrl+End |
Add line comment | Click for keystrokes⌘K ⌘C | Click for keystrokesCtrl+K Ctrl+C |
Remove line comment | Click for keystrokes⌘K ⌘U | Click for keystrokesCtrl+K Ctrl+U |
Toggle line comment | Click for keystrokes⌘/ | Click for keystrokesCtrl+/ |
Toggle block comment | Click for keystrokes⇧⌥A | Click for keystrokesShift+Alt+A |
Multi-cursor and Selection Shortcuts
Effect | MacOS | Windows |
---|---|---|
Insert cursor | Click for keystrokes⌥ + click | Click for keystrokesAlt+Click |
Undo last cursor operation | Click for keystrokes⌘U | Click for keystrokesCtrl+U |
Select current line | Click for keystrokes⌘L | Click for keystrokesCtrl+L |
Select all occurrences of current selection | Click for keystrokes⇧⌘L | Click for keystrokesCtrl+Shift+L |