It may be rare, but sometimes you will need to change some attributes to ensure they don’t share a name. For example, you may have written a standalone function that mentions a completely different element using the same name and you need to differentiate between them.
For large projects, this may mean going through hundreds or thousands of lines at a time. Fortunately, Visual Studio Code has a handy shortcut that lets you select a particular element, line, or column throughout the project and edit all of its instances at once. Continue reading to learn more.
How to change all instances on a Windows PC
If you want to change all instances of a word at once in Windows, you need to do the following:
- Select a particular item or value that you want to change.

- To select all instances of that element, use the keyboard shortcut “CTRL + SHIFT + L”.

- All instances should be highlighted throughout the code, with a cursor at the end.

- With multi-cursor mode on, make changes to the word as needed (or enter additional text later). Click anywhere within the code to exit multi-cursor mode and return to a single cursor.
In case you want to select instances one at a time, the process is a little different and is as follows:
- Choose the item or value you want to change.

- Press “CTRL + D” to select the next instance, then again for the next one, and so on.

- You can change all selected instances directly.

- Exit multi-cursor mode by clicking anywhere within the code.
How to change all instances on a Mac
VS Code works similarly on all platforms. One of the few differences lies in the keyboard shortcuts because each system uses various keyboard settings and defaults.
Once you open your code and determine the word you want to replace, the procedure to change all instances is as follows:
- Click anywhere within the word you want to mass edit.

- Press “CMD + SHIFT + L” to highlight and select all instances in the entire code and enter multi-cursor mode. The cursors go to the end of the word by default and have the word selected.

- Make any changes as you see fit (you are not limited to the selected word and can add text beyond it).

- Close multi-cursor mode by clicking anywhere within the editor.
You can also enter multi-cursor mode by sequentially adding instances of a word or attribute to the selection. That is how:
- Select the word you want to edit.

- Press “CMD + D” to select the next instance in the code.

- Repeat step 2 until you reach a point in the code where you do not need to make any changes.
- Edit the selected word as necessary.

- Click anywhere to return to single cursor mode.

How to change all instances in Linux
VS Code on Linux shares keyboard shortcut settings with Windows.
If you want to change all instances of a word at once, here’s what you do:
- Select the word you need anywhere in the code.

- Press “CTRL + SHIFT + L” to select all instances of that element in the entire code. All instances should be highlighted, with a cursor at the end, and the platform edits in multi-cursor mode.

- Enter the changes you want. The editor will work on all selected changes simultaneously.

- Click anywhere else to return to a single cursor when you’re done.
If you want to be more precise (such as keeping new instances the same), you can select sequentially. That is how:
- Select a word that needs to be changed.

- Press “CTRL + D” to select the next instance. Note that this opens editing with multiple cursors.

- Repeat Step 2 until you reach the part of the code that can remain as is.
- Make edits to the selected words.

- Exit multiple cursor selection by clicking anywhere.
Other tips
VS Code has many other nifty shortcuts, like “Shift + Alt,” which creates a column box for multi-row changes or selects a line by clicking its line number.
Did you know these shortcuts for VS Code? Is there any other code editor you prefer to use? Where do you get your coding materials and instructions? Be sure to share it with us in the comments!