Quick search on filename - android-studio

How can I quick search a class file or entire resource file in android studio?
Eclipse short cuts are
Shift+Ctrl+R for all resource files (include .java file)
Shift+Ctrl+T for all Java class in classpath
Currently, I have changed keymap settings to Eclipse so that I am able to use same short cuts in Android Studio. However, I need to know what is the default shortcut keys in Android Studio.

deniz, you can search everywhere with Double Shift.
It looks like:

To search by file name use the following shortcut keys
On Mac: command + shift + O
On Windows / Linux: control + shift + N

To search only recent files:
ctrl+E
To search all files:
shift + shift

Android Studio Find Files
Mac: ⌘ Command + ⌃ Shift + O
Windows/Linux: Ctrl + Shift + N
[More shortcuts]

Go to Navigate Menu->File or Ctrl+Shift+N.
You Can Also use for All files Search(Double tap Shift):
Shift+Shift
For Viewing Recent Files Search:
ctl+E

You can use search button or double shift

Related

Is it possible to minimize all functions at Android Studio at once?

When working on a class with thousands of lines, minimizing some functions on the IDE makes it very handy to manage the code.
However, everytime we restart the IDE; or close the function: it will be re-opened again.
Is there a way to keep your 'minimizing' preferences?
(for windows Users)
Same time All Methods Collapse : CTRL + SHFT + -
Same time All Methods Expand :CTRL + SHFT + +
(for Mac Users)
Same time All Methods Collapse : Command + SHFT + -
Same time All Methods Expand :Command + SHFT + +
You can go to Code > Folding > Collapse All
In my case the short-cut is CTRL+SHFT+/.
Here is the current way of expanding/collapsing in Windows...
You can go to Setting->Editor->General->Code Folding->see checkbox then check show code folding outline,then apply.(Window OS)
On Mac OS use these short keys:
Shift + Command + -
OR
Preferences-> Editor -> General-> code Folding
press -->
on Windows & Linux
**to collapse --------> ctrl && shift && +
to expand ----------> ctrl && shift && -**
On Mac just use command instead of ctrl
Thank you
Have a look on there -> Go there

android studio / intellij idea goto line number

In Eclipse, if I type cmd+L, it opens a dialog for me to enter a line number and it takes me there in the code. How do I do the same thing in Android Studio? Instead of having to scroll each time I need a specific line number.
Use Command + L for Mac OS X.
IntellijIDEA default keymap reference
Here is the IntellijIDEA default keymap reference. This is applicable to Android Studio too.
You can also find the document from Android Studio -> Help -> Default Keymap Reference
The shortcut to go to a specific line and/or column number is: CTRLG
(archive)
Examples:
Go to line 6
CtrlG6Enter
Go to line 6 and column 8
CtrlG6:8Enter
Go to column 4 on the current line
CtrlG:4Enter
Shortcut References:
AltHK = H̲elp -> Default K̲eymap Reference
IntelliJIDEA_ReferenceCard.pdf (archive)
Android Studio Shortcuts You Need the Most (archive) • PDF version (archive)
The shortcut to go to a particular line number on Android Studio is
On Mac
: Cmd + L
On Linux
: Ctrl + L
On Windows
: Ctrl + G
After this key in the line number in the dialog box that pops up.There is an option to insert the column number as well, but it is not necessary.
If you are in the specific file,
You can use Ctrl + G. And insert the line You wanted. If you want to go to a specific column of the lineNo you can insert lineNo:columnNo.
If you are in some file and you want to navigate into some line of a some other file,
You can simply use default navigation shortcut Ctrl + Shift + N, and insert fileName : lineNo.
NOTE: You don't need to insert the whole name of the file, some text that enables intellij to uniquely identify your file would be good enough. Your input text might turn into red color. But it works. :)
For Windows users shortcut is: Ctrl + G

'Find All' in Android Studio

New to Android Studio and I wanted to find all instances of something across all java files. I read that shift+shift would bring up a 'Search Everywhere' box but it doesn't work. You can see from the image below that the text is in the open class and it says 'Nothing Found'. Am I missing something?
Greg
Try using Ctrl + Shift + F.
You can also try Ctrl + Shift + R.
In Android Studio: version-1.3.1 -- for MAC
Do the following for finding anything in the project:
command + shift + F
Do the following for finding anything and then Replacing in the project:
command + shift + R.
shift+shift is used for searching Classes, Files, Symbols, Actions[About] but not for searching in source files
To find something in code use
//global
Edit -> Find -> Find in Path...
//or
Command + Shift + F
//local
Edit -> Find -> Find...
//or
Command + F
For me I just wanted to find lines where a particular word was used:
so for that Shortcut: (Mac: cmnd+F /).

Comment shortcut Android Studio

I'm searching for useful Android Studio keyboard shortcut for commenting code, as in Sublime Text or Eclipse.
When I press either cmd+/ or cmd+maj+/ nothing happens...
Mac With Numeric pad
Line Comment hold both: Cmd + /
Block Comment hold all three: Cmd + Alt + /
Mac
Line Comment hold both: Cmd + + =
Block Comment hold all three: Cmd + Alt + + =
Windows/linux :
Line Comment hold both: Ctrl + /
Block Comment hold all three: Ctrl + Shift + /
Same way to remove the comment block.
To Provide Method Documentation comment type /** and press Enter just above the method name (
It will create a block comment with parameter list and return type like this
/**
* #param userId
* #return
*/
public int getSubPlayerCountForUser(String userId){}
In spanish keyboard without changing anything I can make a comment with the keys:
cmd + -
OR
cmd + alt + -
This works because in english keyboard / is located at the same place than - on a spanish keyboard
Be sure you use the slash (/) on right side of keyboard.
For Line Comment:
Ctrl + /
For Block Comment:
Ctrl + Shift + /
You can see all keymap in Android Studio: Help ➤ Default Keymap Reference
On Mac and Turkish Keyboard it is (both for commenting out and uncommenting)
line comment:
cmd +.
block comment:
cmd+alt +.
An Example for a Mac OS X 10.5+ with a German layout keyboard without NumPads:
Open Preferences
Search for "Keymap"
Expand "Main menu"
Expand "Code"
Delete all shortcuts (just a suggestion)
Add a shortcut for a single line comment (e.g. Ctrl++)
Add a shortcut for a block comment (e.g. Ctrl+alt +)
This way you can be sure that those keys are not mapped (except if you assigned them before to another function)
Reviewing and Changing Keyboard Shortcuts in Android Studio
Keyboard shortcuts can be configured (and reviewed) via the Settings dialog, accessible via File -> Settings.
Once this dialog appears, to review (and/or add) a shortcut, do the following:
Select Keymap in the list on the left. Note that there is a "Keymaps" option, and depending on the original selection, shortcuts assigned to a given feature differ based on the Keymap.
Type "comment" or text corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned. Each match has a line entry in the list below, and keyboard shortcuts are shown right-justified along with the feature. For example, both CTRL+ALT+SLASH and CTRL+K, CTRL+C are the two assignments for creating a line comment.
To modify a shortcut:
Select the resultant line corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned
Right-click, and select the desired Add or Remove option.
Comment method like pro developers:
Windows/linux:
Line Comment : Ctrl + /
Block Comment : Ctrl + Shift
Method Commenting:
Type `/**` and press `Enter Key`
it will add the comment snippet like we see in standard documentation, give it a try this once.
/**
*
* #param addOpacity
*/
public void setOpacityOnUserImage(boolean addOpacity) {
// Your business logic.
}
In Android studio CTRL + SHIFT + / for windows.
for German Layout (Deutsches Layout) the default is:
for line Comment:
strg + Numpad(/)
for block Comment:
strg+shift+Numpad(/)
I use this sequence (not a 'linear' shortcut but useful anyway):
alt+c then alt+b (holding alt) for block comment
alt+c then alt+l (holding alt) for line comment
(they use the android studio menu)
On PC it's by default set to Ctrl + /. This will toggle commenting a selection or current line.
I am working with a german keyboard and the slash (/) is on the 7 key, meaning access would be Ctrl + Shift + 7. However, this does not work as this is predefined as something with bookmark 7.
I went to settings (search for keymap) and deleted all existing shortcuts. I than added Ctrl + 7, confirmed deletion of bookmark shortcut and now can work well.
For Line Comment: Ctrl + /
For Block Comment: Ctrl + Shift + /
For multiline comment in android studio
select the statement that you want to commented then
use ctrl+shift+/
and for removing mutiline comment
select the statement that you want to uncommented then
use **ctrl+shift+/**
SINGLE LINE COMMENT
For single line comment
use ctrl+/
Ctrl + Shift + / works well for me on Windows.
In LINUX
1.Single line commenting. Ctrl + /
2.For block comment Ctrl + Shift + /
on mac, using uk english keyboard layout to reach quickcomment in android studio the key combination is:
cmd + alt(option) + /
Mac (French-Canadian Keyboard):
Line Comment hold both: Cmd + É
Block Comment hold all three: Cmd + Alt + É
"É" is on the same position as "?/" in english one.
Are you sure you are using / and not \ ?
On Mac I have found by default:
Cmd + /
Comments using // notation
Cmd + Opt + /
Comments using /* */ notation
If you are used with Eclipse, there is something in Settings>Keymap Keymaps: and you can pick Eclipse to keep the same shortcuts.
For Line Comment hold both:
Ctrl + /
For Block Comment hold all three:
Ctrl + Shift + /
Same way to remove the comment block.
In android studio you can do
single comment with (go to line then Ctrl+/)
and
block comment with ( select text then Ctrl+Shift+/)
Also if you want to change color of commented text
go to File->Settings->IDE settings->Editor->Color & fonts->Java->(Line comment or block comment) and change properties.
I prefer it to be green which is used in notepad++ editor.
In the Icelandic MAC keyboard: CMD + -
You can add three slashes.
/// Add comments
this can clear the "comment out code 2 lines" issues.
Mac:
To comment/uncomment one line, use: Ctrl + /.
To comment/uncomment a block, use: Ctrl + Shift + /.
I noticed that command Ctrl + Shift + / works on Windows only in case if there is no indentation on the left. I.e. if you need to comment out an entire function or class, you must additionally press Enter at the top and bottom of the class/function.
It helped me.

Search all the occurrences of a string in the entire project in Android Studio

I've just started using Android Studio (IntelliJ), and I now look for the feature to find the occurrence of a string in any of the files in my project. For example: I want to find all the files that contain the string ".getUuid()"
The search at the top right doesn't give me the correct results, and I don't think I can find this feature under Edit > Find.
Could anybody point me at the right direction?
TLDR: ⌃⇧F on MacOS will open "Find in path" dialog.
First of all, this IDEA has a nice "Find Usages" command. It can be found in the context menu, when the cursor is on some field, method, etc.
It's context-aware, and as far as I know, is the best way to find class, method or field usage.
Alternatively, you can use the
Edit > Find > Find in path…
dialog, which allows you to search the whole workspace.
Also in IDEA 13 there is an awesome "Search Everywhere" option, by default called by double Shift. It allows you to search in project, files, classes, settings, and so on.
Also you can search from Project Structure dialog with "Find in Path…". Just call it by right mouse button on concrete directory and the search will be scoped, only inside that directory and it's sub-directory.
Enjoy!
In Android Studio on a Windows, macOS or Linux based machine use shortcut Ctrl + Shift + F to search any string in whole project. It's easy to remember considering Ctrl + F is used to search in the current file. So just press the Shift as well.
Press Shift twice and a Search Everywhere dialog will appear.
Use Ctrl + Shift + F combination for Windows and Linux to search everywhere, it shows preview also.
Use Ctrl + F combination for Windows and Linux to search in current file.
Use Shift + Shift (Double Tap Shift) combination for Windows and Linux to search Project File of Project.
You can open the Find in Path dialog by pressing:
Ctrl + Shift + F
Android Studio 3.3 seems to have changed the shortcut to search for all references (find in path) on macOS.
In order to do that you should use Ctrl + Shift + F now (instead of Command + Shift + F as wrote on the previous answers):
UPDATE
To replace in path just use Ctrl + Shift + R.
Android Studio Version 4.0.1 on Mac combination is for me:
Shift + Control + F
And for all of us who use Eclipse keymaps the shortcut is Ctrl+H. Expect limited options compared to eclipse or you will be disappointed.
In Android Studio on a Windows or Linux based machine use shortcut Ctrl + Shift + R to search and replace any string in the whole project.
What you want to reach is that, I believe:
cmd + O for classes.
cmd + shift + O for files.
cmd + alt + O for symbols. "wonderful shortcut!"
Besides shift + cmd + f for find in path && double shift to search anywhere.
Play with those and you will know what satisfy your need.
use ctrl + shift + f on windows
Press SHIFT 2 times and you can search Every-where , both Class and Method() in the project.
Ctrl + N for finding only Class name.
Ctrl + E for Recent Files.
Use Ctrl + Alt + F combination in Ubuntu.
On a mac use shift + cmmd + f
To get rid of the screen press esc
I use IntelliJ IDEA
version: 2019.2.3 (Community Edition)
Build #IC-192.6817.14, built on September 24, 2019
Runtime version: 11.0.4+10-b304.69 x86_64
In Android 3.6 on a Mac if you want to export the results to a text file then do the following
Command+Shift+F then enter the text you want to search
Then on Bottom Right click on "Open In Find Window"
Then Right Click On Found Occurrences
Then Export To Text File
Once in text file you can find and replace to remove, sort lines etc... please see screenshots for assistance.

Resources