vanshaj
vanshaj

Reputation: 549

Is there any way in vscode to know where the current the file has been imported?

Are there any extensions/features in vs-code which could let me know where the current file is imported? I usually do a global search of the filename but it is time consuming when the file name is similar to any variable or there are similar named files.

Upvotes: 23

Views: 25571

Answers (5)

Abdul Mattee
Abdul Mattee

Reputation: 302

NO EXTENSION REQUIRED

Yes, We can find the references of a file in VSCODE like this: Right-click on the file and then select Find References.

VSCODE will show all the references/imports of the file. image reference

Upvotes: 7

Marzieh Mousavi
Marzieh Mousavi

Reputation: 1624

- find unused exports in project:

you can use this extension in vscode to find all unused exports

+ find name references (e.g. used exports) in project:

click on name then press shift+alt+F12

enter image description here

Upvotes: 1

Nesha25
Nesha25

Reputation: 408

If you are limiting your search to the current open workspace / folder, you can

  1. do a search for 'import' using the magnifying glass or pressing ctrl+shift+s
  2. open the results in editor by either clicking the link that says 'Open in editor' or by pressing alt+enter
  3. In the document that opens, search for the name of your module.

In this way you will discover all of the imports that involve your module, regardless of whether you have used 'import mymodule' or 'from mymodule import myfunction' or anything else. I'm specifically thinking of how I'd structure a python project, but if you are using another language, you can alter the search in a way that works for the way your language does imports.

Upvotes: 0

Vasil Enchev
Vasil Enchev

Reputation: 1726

Right-click > Go to References (Shift + F12) There is also an extension to change the appearance of how references show https://marketplace.visualstudio.com/items?itemName=jrieken.references-plusplus

Upvotes: 0

Interface
Interface

Reputation: 342

You can do a right-click on every function / variable or class. Then you choose "Find all references" to show where each function / variable or class is called. For this you do not need an extension, because it is a standard feature of vscode

Upvotes: 14

Related Questions