[android] Find and replace Android studio

Is there a way to find and replace all occurrences of a word in an entire project( not just a single class using refactor -> rename) and also maintain case, either in android studio or using a command line script?

For example, Supplier has to go to Merchant, supplier -> merchant, SUPPLIER -> MERCHANT. My boss wants me to change all instances of supplier with merchant for a project im working on. Ive been doing it for about an hour and i know im wasting my time. Let me know of any time saving suggestions.

This question is related to android android-studio refactoring renaming

The answer is


I think the shortcut that you're looking for is:

Ctrl+Shift+R on Windows and Linux/Ubuntu

Cmd+Shift+R on Mac OS X

ref: source


If you use refactor->rename for the name of the file, everywhere the file is used in your project the refactor will replace it.

I have already rename variables, xml file, java file, multiple drawable and after the operation I could build directly without error.

Do a back-up of your project and try to see if it work for you.


I think the previous answers missed the most important (non-trivial) aspect of the OP's question, i.e., how to perform the search/replace in a "time saving" manner, meaning once, not three times, and "maintain case" originally present.

On the pane, check "[X] Preserve Case" before clicking the Replace All button

This performs a case-aware "smart" replacement in one pass:

apple -> orange
Apple -> Orange
APPLE -> ORANGE

Also, for peace of mind, don't forget to check the code into the VCS before performing sweeping project-wide replacements.


Press Ctrl+R to find and replace codes in the class where you are...


ctrl + H ..... its give option to replace word from class.


Try using: Edit -> Find -> Replace in path...


On Windows:

Find : Ctrl+F

Find And Replace In Single Class: Ctrl+R

Find And Replace In Whole Project: Ctrl+Shift+R

on OS X ,it is similar, just replace Ctrl with Command


The shortcuts are

On Windows : Ctrl+Shift+R

On Mac : Cmd+Shift+R


Use ctrl+R or cmd+R in OSX


In Android studio, Edit -- > Find --> Replace in path, this will check in whole project including comments and code.


Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-studio

A failure occurred while executing com.android.build.gradle.internal.tasks "Failed to install the following Android SDK packages as some licences have not been accepted" error Android Gradle 5.0 Update:Cause: org.jetbrains.plugins.gradle.tooling.util This version of Android Studio cannot open this project, please retry with Android Studio 3.4 or newer WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()' Flutter plugin not installed error;. When running flutter doctor ADB.exe is obsolete and has serious performance problems Android design support library for API 28 (P) not working Flutter command not found How to find the path of Flutter SDK

Examples related to refactoring

Find and replace Android studio How to change a package name in Eclipse? How do I deal with "signed/unsigned mismatch" warnings (C4018)? How to use IntelliJ IDEA to find all unused code? What are some alternatives to ReSharper? Replace Multiple String Elements in C# Python: avoiding pylint warnings about too many arguments Detecting superfluous #includes in C/C++? How to simplify a null-safe compareTo() implementation? Find unused code

Examples related to renaming

Find and replace Android studio