Photo by Rahul Mishra on Unsplash
So I was refactoring a config file at some ungodly hour — something like 60 lines of nearly identical JSON keys — and my coworker walked by and watched me manually editing each one. He just stared at me for a second, said nothing, and reached over to hit three keystrokes. Suddenly there were cursors on every single line simultaneously. I felt like an idiot. That was the day I actually sat down and learned VS Code multi-cursor editing properly, and I haven't looked back since.
If you're still editing repetitive code line by line, this post is going to feel like cheating. Good.
The Basic Multi-Cursor Shortcut Everyone Knows (But Uses Wrong)
Most people know you can hold Alt (or Option on Mac) and click to drop multiple cursors wherever you want. That's fine. But I see people using this to click on 30 individual lines, which defeats the entire purpose. That's like using a nail gun to tap in one nail at a time.
The move you actually want for stacked, consecutive lines is Ctrl+Alt+Down (or Cmd+Option+Down on Mac) to add a cursor one line below, repeatedly. Hold it down and watch the cursors stack. Then just type and every line gets the same edit simultaneously. Want to go upward? Ctrl+Alt+Up. Simple, fast, and honestly satisfying in a weird way.
The One That Actually Saves the Most Time: Select All Occurrences
Here's the thing though — the real power move is selecting every instance of a variable, class name, or string across your entire file at once.
Highlight any word, then hit Ctrl+Shift+L (Windows/Linux) or Cmd+Shift+L (Mac). VS Code will drop a cursor on every single occurrence of that selection in the file. Now you can rename, wrap, delete, or transform all of them at the same time. No regex. No find-and-replace dialog. Just... done.
There's also Ctrl+D (Cmd+D on Mac) which selects the next occurrence one at a time — useful when you want to be selective. Hit it a few times to grab just the ones you want, skip one with Ctrl+K, Ctrl+D, then edit. I use this probably a dozen times a day.
Column (Box) Selection — The Underrated One
This one genuinely surprises people. If your code has a block of text aligned vertically — like a list of variable assignments — you can select a column across multiple lines and edit all of them at once.
Hold Shift+Alt and then drag your mouse down (or use Shift+Alt+Down arrow key). You'll get a rectangular selection, not a line-by-line one. This is perfect for things like adding a prefix to a bunch of property names, or ripping out a column of data you don't need.
Honestly, this is the feature I show new devs first because it looks like magic and it gets them interested in learning the rest.
Insider Trick #1: Multi-Cursor With Find and Replace
Most people treat Find & Replace (Ctrl+H / Cmd+H) as a separate tool from multi-cursor editing. But here's something a lot of folks miss — when you're in the Find widget (Ctrl+F), you can click the little "Select All Occurrences" button (or press Alt+Enter) and it dumps you back into the editor with every match already selected as a multi-cursor.
This means you can use regex to find a complex pattern, hit Alt+Enter, and then surgically edit every match live in context. Way more intuitive than trying to write a regex replacement string — especially when you just want to see what you're changing before you commit to it.
Insider Trick #2: Middle Mouse Button for Cursors
If you're on a machine with a middle mouse button, you can hold Alt and middle-click drag to do a column selection without using the keyboard at all. It's a small thing, but on a large monitor with a lot of vertical code, it's surprisingly fast.
(Side note: VS Code's settings for multi-cursor behavior live under File > Preferences > Settings — search for editor.multiCursorModifier if you want to swap Alt for Ctrl as your multi-cursor key. Some people prefer it, especially if Alt conflicts with system shortcuts on Linux.)
Practical Example: Renaming Object Keys in Bulk
Say you've got something like this:
const config = {
user_name: "",
user_email: "",
user_phone: "",
user_address: "",
};
You need to strip the user_ prefix from every key. Just double-click user_name to select it, then use Ctrl+D three more times to grab all four occurrences of user_ (you'd select just that prefix part). Then delete. Four lines, one action. Done in two seconds.
Now here's where it gets tricky — sometimes the occurrences you're selecting with Ctrl+D are context-dependent and you'll accidentally grab one you didn't want. That's what Ctrl+K, Ctrl+D is for — it skips the current selection and jumps to the next one without adding a cursor there. Think of it as "skip this one."
Quick Reference Cheat Sheet
Since I know someone's going to want this in a copy-paste format:
Add cursor below: Ctrl+Alt+Down (Cmd+Option+Down on Mac)
Add cursor above: Ctrl+Alt+Up (Cmd+Option+Up on Mac)
Select next occurrence: Ctrl+D (Cmd+D on Mac)
Skip current occurrence: Ctrl+K, Ctrl+D (Cmd+K, Cmd+D on Mac)
Select all occurrences: Ctrl+Shift+L (Cmd+Shift+L on Mac)
Column selection drag: Shift+Alt+drag
Select all find matches: Alt+Enter (while Find widget is open)
In my experience, the biggest barrier to using multi-cursor editing consistently isn't knowing the shortcuts — it's building the reflex to reach for them instead of defaulting to manual edits. The next time you catch yourself about to edit three or more similar lines by hand, stop. That's your signal.
Hope this saves you a few hours of tedious editing. Your future self will thank you — probably at 2am during a refactor.
Related: VS Code Tips and Tricks That Actually Save You Time (Not Just the Obvious Ones)
๋๊ธ
๋๊ธ ์ฐ๊ธฐ