Add undeclared variable to autofill

There are times where I have already written some value, and want to put it into a variable rather than using the value directly. So I copy the value, replace it with the name of a currently undeclared variable, then declare the variable and paste the value

It would be useful if the undeclared variable showed in autofill

5 Likes

Hmm, I’m not sure I agree with this suggestion exactly as posted. If we start suggesting undeclared-but-used variables there’s a risk of Autocomplete misleading people (e.g. someone misspells a variable elsewhere in the script and then Autocompletes it).

Maybe instead, this points to the need for a “Refactor → Extract Variable” action that does the common expression replacement for you. Would that address your workflow?

1 Like

I agree with putting it in autofill and suggesting typos. Something like extract variable from VSCode would be great Refactoring source code in Visual Studio Code