anchvy's website logo

VSCode Tip: Find all usage of specific variable across files in workspace

Issue

Sometimes, we might have to update a variable or a function name that is being used widely in your large project. And unluckily that the existing name is very common and being used for other stuff as well.

Using a common feature like Find all and replace to search the actual text might not be effective because you might update the wrong one. So, we have to check it one by one whether we can update it or not.

Which way is easiest for this case?

Fix

The VSCode provides us a very useful feature to solve this kind of issue. It is a Find All References feature.

How to use "Find All References"

Let's say, we need to update this type name from Article to ArticleItem

Then, we have to select the type name and right click > Find All References

After that, we will see all current references of Article type and we can update it easily

By doing this, we can make sure that we are updating the correct items

Remarks

This feature works best against modern JS that uses import/export

Latest articles!

Memo: Web performance runtime Q&A

CSS: PX to REM Calculator

Memo: What I can see from POPCAT.CLICK as a Frontend engineer