xsburg / vscode-javascript-booster

Sprinkle extra refactorings, code actions and commands over your JavaScript! 🍩 TypeScript and Flow are first class citizens as well!
https://marketplace.visualstudio.com/items?itemName=sburg.vscode-javascript-booster
159 stars 13 forks source link

Feature Request: Introduce Variable #46

Open Oripi opened 2 years ago

Oripi commented 2 years ago

Hi, There's a really useful feature that i miss from intellij/webstorm and that's the introduce variable: https://www.jetbrains.com/help/idea/extract-variable.html

image

it allows you to put the caret over any part of an expression (usually a method that returns a value but is not assigned to a variable) and when selecting the refactor command it assigns it to a variable. example:

// before refactor:
function doSomething() {
  return 'hello';
}

something();

// after putting caret at the end/middle/inside parentheses of method and selecting refactor command (the variable name is selected to easily give a new name):
const variableName = something();

would love to see this feature in this great extension :)