Find and replace Android studio

后端 未结 10 1634
南旧
南旧 2020-12-07 08:18

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 androi

相关标签:
10条回答
  • 2020-12-07 08:28

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

    0 讨论(0)
  • 2020-12-07 08:29

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

    0 讨论(0)
  • 2020-12-07 08:31

    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.

    0 讨论(0)
  • 2020-12-07 08:32

    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.

    0 讨论(0)
  • 2020-12-07 08:38

    The shortcuts are

    On Windows : Ctrl+Shift+R

    On Mac : Cmd+Shift+R

    0 讨论(0)
  • 2020-12-07 08:40

    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

    0 讨论(0)
提交回复
热议问题