Question

[Solved] 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.

Solution #1:

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

Respondent: Krylez

Solution #2:

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

Respondent: sooglejay

Solution #3:

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

Respondent: Zoombie

Solution #4:

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

Respondent: Simon

Solution #5:

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.

Respondent: Pull

Solution #6:

Use ctrl+R or cmd+R in OSX

Respondent: santaclos

Solution #7:

The shortcuts are

On Windows : Ctrl+Shift+R

On Mac : Cmd+Shift+R

Respondent: JGPhilip

Solution #8:

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

Respondent: Dinesh

Solution #9:

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

Respondent: dazed

Solution #10:

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.

Respondent: Pete Alvin

Solution #11:

This is very simple.

Use Ctrl+R for Windows .

Use Cmd+R for mac.

Respondent: Deepak gupta

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy