Select expression occurrencespro

Start a multi-cursor selection on several occurrences of the same expression.

P42 for VS Code
Pro & Business
Select expression occurrences

The "select expression occurrences" code action finds additional occurrences of the currently selected expression (full text selection) and starts a multi-cursor selection on them. With the multi-cursor selection, you can edit all occurrences in parallel.

The code action uses expression equality, not text equality. This means that only expressions that have the same variable bindings and this scope (when this is part of the expression) are considered as additional occurrences.

Why is this refactoring helpful?

Editing multiple occurrences of an expression is useful in many cases, e.g., to fix code snippets after copy-pasting them.

Visual Studio Code allows you to select multiple occurrences of the same text, but this can be imprecise especially for very short variable names. The "select expression occurrences" uses semantic equality, not text equality.


Related Code Assists

Learn More

Available In