homewritingsthoughts
中

Essential VS Code shortcuts

Apr 20, 2024

·

2 min read

tl;dr:Useful VS Code shortcuts for a more efficient workflow.

At work, there are often situations where code needs to be processed in bulk. I used to click everything with the mouse, which was painfully primitive. So I decided to spend some time learning VS Code shortcuts.

Search, replace, and bulk operations

Select multiple occurrences

To select every occurrence of the currently selected variable and edit them in bulk, press Ctrl+F2. It selects all matching fields so they can be handled together.

Select all occurrences with Ctrl+F2

You can also use Alt+Click to place multiple cursors by clicking.

Select with Alt+Click

Even more convenient is Ctrl+D: it selects the occurrence at the cursor. Press it repeatedly to select subsequent matching occurrences.

Select with Ctrl+D

Search and replace

Ctrl+F is the classic search shortcut, while Ctrl+H opens replace. After entering a replacement, press Enter to apply it one occurrence at a time.

Search and replace with Ctrl+F/H

Display

ShortcutAction
F11Toggle full-screen mode
Ctrl+BToggle the sidebar
Ctrl + Shift + VPreview a Markdown file

Windows

ShortcutAction
Ctrl + Shift + NOpen a new window
Ctrl + Shift + WClose the current window
Ctrl + PQuick open a file

April 20, 2024, in Suzhou