Edit selected repeated text with VS Code multi-cursors

Command-D adds the next matching occurrence to a selection. Command-U undoes the last cursor operation, giving you a way to correct the selection set.

Scope
Visual Studio Code · Current vendor documentation checked 3 November 2026; no running-app compatibility test is claimed.
Keyboard and customization
Documented Mac defaults; punctuation and function keys depend on keyboard layout and hardware.. User bindings, app versions, focused controls and installed extensions can change a command. Inspect the active app menu or its shortcut editor when a listed combination differs.
Review basis
Documentation reviewed 2026-11-03 by Codex — primary-documentation and editorial review; no hands-on runtime test. These bindings were not tested in a running app for this guide.

Select an exact example

Begin with the exact text you intend to change and inspect the next match before adding more cursors. A text occurrence is not necessarily the same semantic symbol. Similar names inside comments, strings or unrelated scopes can match too, so a multi-cursor edit needs deliberate scope checking.

Build the selection set gradually

Add a few matches and verify each highlighted location before typing replacement text. If the latest cursor is wrong, use the cursor-undo command rather than continuing and planning to repair the result afterward. Select-all-occurrences is broader and should be used only after checking that the matching scope is suitable.

Choose rename for a semantic change

If your goal is to rename a variable or symbol across its references, a language-aware rename can be more appropriate than replacing text matches. Multi-cursors are useful for deliberate textual edits, but they do not by themselves understand the meaning of each occurrence or guarantee that all relevant references are covered.

Documented commands for this workflow

Scroll the table sideways to see every column.

ActionKeysWhen to use it
Add the next matching occurrenceCommand-DBuild the selected matches incrementally and inspect their contexts. ↗
Undo a cursor-selection stepCommand-UA cursor operation, distinct from undoing the file’s text edits. ↗
Select all current-text occurrencesShift-Command-LReview the resulting range before typing a replacement. ↗

Sources and corrections

Found a mismatch? Email pashaseenainc@gmail.com with your app version, macOS version, keyboard layout and the command. Please leave personal document names out.

Keep going

Right there when you need it.

Keep a compact shortcut reference in your Mac’s menu bar.

Explore the native Mac app