Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Search for place where variable is given value

Is there any mechanism within VS Code (including plugins) to search for the place where a variable is given a value? I often search for myvariable = but that doesn't catch things like:

{ myvariable } = ...
[ myvariable ] = ...

function myfunc(myvariable) { }
myfunc(myvalue)

I'm working with JavaScript exclusively.

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Not sure this is the right stack exchange for this question, but yes, there is a way to find these. The article on code navigation will help you further. Basically, VS Code has a command "Find references" (for me it's keybind F12 or ctrl+shift+F12 for a "full" version, but I don't know if this is the default) which will show you where a variable/type is declared and used.

As far as I know, there isn't an easy way to find only the places where a variable gets assigned. But these are included in the references search.

about 4 years ago · Juan Pablo Isaza Report

0

You can use Ctrl+Shift+O to open the Go to symbol in editor menu.

Here you can search for variable definitions, and once selected your cursor will automatically be moved to the definition.

Example

Say my file looks like this:

enter image description here

I press Ctrl+Shift+O to bring up this:

enter image description here

Then I can select an item to move my cursor to the definition like this:

enter image description here

about 4 years ago · Juan Pablo Isaza Report

0

Here is another idea just for fun. It uses an extension I wrote, Find and Transform, that handles your request pretty easily (as long as you can make the appropriate regex ;>}).

With this keybinding:

{
  "key": "alt+y",                  // whatever keybinding you want
  "command": "findInCurrentFile",
  "args": {
    "find": "${selectedText}(?=\\s*[}\\]]?\\s*=)",
    "isRegex": true,
  }
}

It'll get your selected text (which may just be the word under the cursor - see demo) and uses a positive lookahead to find the examples you mentioned in your question. The match will be scroll-revealed if necessary. Ctrl+U to return the cursor to your previous position.

selected text with reveal demo

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!