Mahdi
Mahdi

Reputation: 6389

what is the shortcut for find a usage of XML file in android studio?

As you know there is many useful shortcuts that improve you coding speed.

One of them is find usage of Class or Method that works with Alt+F7 or Ctrl+b. they works on methods and class names but I wonder how I can find a Usage of XML file like Layout Without Search in project and use Find Usage.

Because the name of XML file is not in the file Like classes and I Always search it's name in whole project. I googled but could not find any answer.

Upvotes: 11

Views: 10938

Answers (4)

Extremis II
Extremis II

Reputation: 5583

For Mac users the shortcut is

  1. First select the file in project view (⌥ + (fn) + F1)

    select in project view hit enter to select 1st option or select select scroll from source

  2. show usage of file (⌥ + (fn) + F7)

    enter image description here
    hit enter to open the file

Upvotes: 0

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29794

From IntelliJ IDEA Documentation:

Finding Usages in the Current File

To find usages of a symbol in the current file:

  1. Click the desired symbol in the editor, or in the Structure view.
  2. On the main menu, choose Edit | Find | Find Usages in File, or press Ctrl+F7. The encountered usage is highlighted in the editor.

But this didn't work in Linux, instead use ALT+F7

Upvotes: 2

Enzokie
Enzokie

Reputation: 7415

My personal preference is ctrl+shift+f. It will display a popup dialog in which you can type the thing that you are searching and it will look in your entire project folder.

Alternately there is already a Find Usage feature in xml when you right click it. And it does shows the file that uses it.

enter image description here

In my example I did find the use of my analytics_debug.xml then a mini console below will show indicating which file uses it. Selecting the file in usage console redirects you to the exact line of code in which the XML is called.

I reproduce this usecase in Ubuntu 16.04, A.S. version 2.1.1.

Upvotes: 4

Charuka Silva
Charuka Silva

Reputation: 13153

All keys are given for windows

CTRL + F for find keywords in a single file

Can do it like this Find usage of an XML| ALT + F7 after you select the XML layout

enter image description here

There is another way(not sure you gonna like it) .. Try to delete a xml and it will not be deleted at the first time.It will show you all the usages of it ask you to confirm you deletion. You can see all the usages at the terminal,so that way you can find them all.

enter image description here

click on view usages button it will show them all

For any short-key File -> Settings -> Keymap -> (you can even Choose Eclipse/Visual Studio short key types in android studio)

Here are some default short keys for windows

Format code | CTRL + ALT + L

Add unimplemented methods | CTRL + I

Show logcat | ALT + 6

Build | CTRL + F9

Build and Run | CTRL + F10

Find | CTRL + F

Find in project| CTRL+SHIFT + F

Find and replace | CTRL + R

Find and replace in project | CTRL + SHIFT + R

Override methods | CTRL + O

Show project | ALT + 1

Hide project - logcat | SHIFT + ESC

Collapse all | CTRL + SHIFT + NumPad +

View Debug Points | CTRL + SHIFT + F8

Expand all | CTRL + SHIFT + NumPad -

Open Settings | ALT + s

Select Target (open current file in Project view) | ALT + F1ENTER

Search Everywhere | SHIFTSHIFT (Double shift)

Code | Surround With | CTRLALT + T

Create method form selected code | ALT + CTRL

Upvotes: 15

Related Questions