Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

115
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda