Skip to main content

Select Next Occurrence in VS Code (macOS)

Press Command + 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

PlatformShortcut
macOSthis pageCommand + D
Windows
Linux

More VS Code shortcuts: General

  • Toggle Comment
  • Find
  • Find and Replace
  • Go to Symbol
  • Go to Line

All 71 VS Code shortcuts for macOSThe full list has a search and a printable PDF.

Questions

What is the VS Code shortcut for Select Next Occurrence on macOS?

⌘D (Command + 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 Windows and Linux?

On Windows it is Ctrl+D. On Linux it is Ctrl+D.