Reputation:
I'm in the middle of building a Java project on NetBeans. I want to change one of my variable's name to something else, but the problem is
the variable name has been used nearly 50 times in my project and I don't want to change it one by one and carry the risk of missing one or two here and there. So is there any way I can select and change all instance of this particular variable name at the same time?
one of the method in the project has the same name as the variable, however, I do NOT want to change the method's name. I only want to change the variable's name. Is there any way that this can be accomplished?
Upvotes: 3
Views: 17785
Reputation: 347
Sometimes ctrl + R
does not work for me. So in that case, try ctrl + F
to open the Find/Replace
window an then write your variable in the search field to find all the instances of that variable, and then in replace text field, enter the text or variable name you want to replace with current variable. and then click on Replace All
button at the bottom.
I know that is not a good approach but it was helpful for me when my ctrl + R
was not working for any unknown reason....
Upvotes: 1
Reputation: 633
The problem you are facing can be solved by the process called Refactoring. Place the cursor inside a variable you want to rename and press Ctrl + R. Then type other name and editor will change all occurrences of that variable.
Upvotes: 7