Apply Changes For Multiple Sections Of Code

Viewed 79

I have made an edit to a section of my code(Android Studio) which is duplicated in 8-9 other sections with minor changes. I want to change a portion of this code and make those changes reflect in the 8-9 other sections of code(they all have the same couple errors). Is there any way I can accomplish this without having to go through and complete the same changes on each individual section of code?

Thank you!

2 Answers

Just double-click on the variable or function you want to change and press CTRL + SHIFT + R. This kind of window will appear on Android studio, which will tell you all the places where the selected part is in your project. And you can change the code where you want to change and let it be the same if you don't want to change it and skip that and go to the next one.

CRTL + SHIFT + R shortcut for replacing the selected code

If they appear to be exactly the same, you can use the following shortcut to replace all matches.

ctrl + shift + r

Related