Refactor local variable name using Visual Studio Code

Use Rename Symbol. It is defined by default with Ctrl + F2.

However, keep in mind that the variable, definition, function, etc., that you're changing, will be changed in the file itself, not only the scope. Visual Studio Code for now doesn't have an implementation for renaming a variable in a scope (for example, a variable inside a function). So keep that in mind.

Visual Studio Code - change all occurrences


Use rename symbol instead of the standard find/replace. Rename is bound to F2 by default.

Rename symbol will know to only touch the local roles references in your example. Visual Studio Code ships with rename support for JavaScript and TypeScript. Other languages may require installing a language extension.


For macOS users: Use Fn + + F2 to rename a variable inside a code block.