Is there a possibility to extract a method with a shortcut in Visual Studio Code when writing TypeScript?
function printOwing() {
printBanner();
// Print details
console.log("name: " + name);
console.log("amount " + amount);
}
So that with one shortcut I could extract the printDetails()
:
function printOwing() {
printBanner();
printDetails();
}
function printDetails() {
console.log("name: " + name);
console.log("amount " + amount);
}
Similar to Eclipse → right click → Refactor → Extract method….
Extract method and extract function were added in Visual Studio Code 1.16: JavaScript and TypeScript refactorings
To use them, select a block of code and then either click on the lightbulb or use the editor.action.quickFix
action (cmd.) to view the list of refactorings.
You can also setup a keybinding for extract method:
{
"key": "ctrl+shift+r ctrl+e",
"command": "editor.action.codeAction",
"args": {
"kind": "refactor.extract.function"
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With