Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code: How to refactor(rename variable) in an Angular template file?

I want to rename a variable used across an angular template file (i.e. an xxx.component.html file). This could be done with Shift + F6 shortcut in WebStorm. How to do it in vscode? F2 doesn't help.

like image 213
djy Avatar asked Oct 21 '18 10:10

djy


People also ask

How to rename a variable across an angular template file?

I want to rename a variable used across an angular template file (i.e. an xxx.component.html file). This could be done with Shift + F6 shortcut in WebStorm.

What is refactoring in Visual Studio Code?

Source code refactoring can improve the quality and maintainability of your project by restructuring your code while not modifying the runtime behavior. Visual Studio Code supports refactoring operations (refactorings) such as Extract Method and Extract Variable to improve your code base from within your editor.

How do I rename an item using the refactor tool?

This refactoring tool will accurately perform the renaming action. Highlight or place the text cursor inside the item to be renamed: Next, use your keyboard or mouse as follows: Press Ctrl+R, then Ctrl+R. (Note that your keyboard shortcut may be different based on which profile you've selected.) Select Edit > Refactor > Rename.

How do I rename a file in Visual Studio Code?

Renaming is a common operation related to refactoring source code and VS Code has a separate Rename Symbol command (F2). Some languages support rename symbol across files. Press F2 and then type the new desired name and press Enter.


1 Answers

You need to use Ctrl + F2 combination to select the word and then type the new word , It will select all and replace with the new one

Ctrl + F2

like image 159
Sajeetharan Avatar answered Oct 24 '22 07:10

Sajeetharan