Select Next Occurrence in VS Code (Windows)
Press Ctrl + D to select the word under the cursor, and with each further press the next place where it occurs.
What it does
The first press selects the word the cursor is in. Every further press adds the next occurrence of that text to the selection and puts a cursor there, so what you type next changes all selected places at once. It suits renaming a variable in a short block or editing a few similar lines, where a full find and replace would be more than the job needs.
The same shortcut on other platforms
| Platform | Shortcut |
|---|---|
| Windowsthis page | Ctrl + D |
| macOS | |
| Linux |
More VS Code shortcuts: Editing
- Select All Occurrences
- Move Line Up
- Move Line Down
- Delete Line
- Toggle Comment
All 35 VS Code shortcuts for WindowsThe full list has a search and a printable PDF.
Questions
What is the VS Code shortcut for Select Next Occurrence on Windows?
Ctrl+D. Press it to select the word under the cursor, and with each further press the next place where it occurs.
What is the shortcut for Select Next Occurrence in VS Code on macOS and Linux?
On macOS it is ⌘D. On Linux it is Ctrl+D.