How to Select and Edit Multiple Occurrences in VS Code (Ctrl+D)
Windows: Ctrl+D
Mac: Cmd+D
Linux: Ctrl+D
Ctrl+D (Cmd+D on Mac) selects the word under the cursor on first press, and each additional press adds the next matching occurrence further down in the file to a growing multi-cursor selection — letting you type a single edit that applies simultaneously at every selected location.
**Step by step**: place the cursor inside (or select) the word you want to change, press Ctrl+D once to select that first instance, then press it again to add the next occurrence, and again for each one after that. Once you've accumulated all the occurrences you want, just start typing — the replacement text is inserted at every selected cursor location at once.
**Skipping an occurrence you don't want to change**: if Ctrl+D lands on a match you don't want included, most VS Code configurations let you skip it without losing your other selections — checking the Keyboard Shortcuts reference for 'Move Last Selection to Next Find Match' shows the exact binding in your version, since this specific skip behavior isn't always bound to a key by default and may need manual assignment.
**Why this beats Find & Replace for some edits**: Find & Replace operates blindly across however many matches exist, applying the same replacement to all of them in one pass (or asking you to confirm each one individually, which is slow for many matches). Ctrl+D instead builds a visible, editable multi-cursor selection you can inspect before typing anything, and because you're typing directly rather than specifying a replacement string in a separate field, you can make a context-aware edit (like adding a suffix that varies, or fixing each instance slightly differently by editing further after the initial multi-edit) that a blind Find & Replace can't do in one pass.
**Selecting all occurrences immediately**: if you already know you want every single match changed identically, Ctrl+Shift+L selects all occurrences of the current selection across the whole file in one keystroke, skipping the repeated Ctrl+D presses — faster when there's no need to selectively skip anything.
**A scope gotcha**: Ctrl+D only operates within the current file, not across the whole workspace. For a rename that needs to apply project-wide and is aware of actual code semantics (not just text matching), F2 (Rename Symbol) is the correct tool instead, since it uses the language server to update only genuine references to that symbol, not coincidental text matches elsewhere.
**Related shortcuts**: Ctrl+Shift+L for selecting every occurrence at once rather than incrementally, and F2 for a semantically aware project-wide rename when Ctrl+D's plain text matching isn't precise enough.
**Mistake to avoid**: pressing Ctrl+D repeatedly without checking each newly added selection can accidentally include an occurrence inside a comment or string literal that happens to contain matching text but isn't actually a code reference you meant to change — a quick visual scan of the highlighted selections before typing the replacement avoids editing text you didn't intend to touch.
**Undo behavior with multi-cursor edits**: a single Ctrl+Z after a multi-cursor edit undoes the entire simultaneous edit across all selections at once as one atomic action, not one occurrence at a time, which is generally the expected behavior but worth knowing if you're trying to selectively revert just one of several edited occurrences rather than all of them together.
**Combining with Alt+Click for irregular multi-cursor patterns**: Ctrl+D is specifically for repeated occurrences of the same text, but Alt+Click (Option+Click on Mac) at arbitrary points in a file adds independent cursors anywhere at all, regardless of matching text — combining both techniques (Ctrl+D for pattern-based selection, Alt+Click for manually placed additional cursors) covers the small set of edits that don't fit either technique alone.