Android Studio Short Cut Developmet Tip's

Share:

 Navigate to Nested File

Sometimes you have a couple of files that have the exact same name but are in different directory. E.g. many AndroidManifest.xml in different modules.
So when you try to navigate to a file, you get a bunch of results and have to think which one you need.
By prefixing a portion of the path and adding a slash to your search query, you can get the right one on the first try.
Shortcut: 
  Mac: Cmd+O, then type it!
  Windows/Linux: Ctrl+N, then type it!
Navigate to Nested File
Navigate to Nested File

Open File Externally

With this shortcut, you can open your file navigator to the current file or any of its parent folder simply by clicking on its tab.
Shortcut (on a file tab):
  Mac: Cmd+Click
  Windows/Linux: Ctrl+Click
Open File Externally
Open File Externally

Find Completion

When you do a find in files, invoking the autocomplete shortcut will suggest words that are in the current file.
Shortcut:
  Mac: Cmd+F , type something and autocomplete
  Windows/Linux: Ctrl+F, type something and autocomplete
Find Completion
Find Completion

Next Change

This will cycle through all changes in the current file. The changes are based on the previous version of the file currently under source control.
A nice thing about this shortcut is that it will also open a bubble showing the previous value and allowing you to:
 Revert to the old value
Show a side by side diff
Copy the old value to the clipboard
If you want to open this popup using the mouse, you can also click the blue bar in the gutter.
Shortcut:
  Next: Ctrl+Alt+Shift+Up
  Previous: Ctrl+Alt+Shift+Down
Next Change
Next Change

Next Highlighted Error

When there are a couple of errors and warnings in a file, you can quickly cycle through them using this shortcut. Very useful when you have a couple errors in a file or if you are resolving merge conflicts by hand (the "<<<<<<<"  thing in the middle of a java file is an error right!)
By default it won't make a difference between a warning and an error. If you want to prioritize errors, you can set it in Preferences → Editor → Error Highlighting → 'Next Error' action goes to high priority problems only. Once all errors are cleared, it will cycle through warnings.
Shortcut:
  Next: F2
  Previous: Shift+F2
Next Highlighted Error
Next Highlighted Error

Negation Completion

Sometimes you auto complete a boolean and then you go back to the beginning to add a "!" in front of it to negate it.
Turns out that that you can skip that part by pressing the "!" key instead of the enter key to auto-complete it.
Shortcut (during code completion on a boolean)

Negation Completion
Negation Completion

Smart Type Completion

Code completion is already pretty smart right? Well it turns out that there is a shortcut for something even smarter. If you invoke it, it will try to complete only with parameters that have business being there. So when you complete for a method parameter, it will only show objects that fit the signature.
Additional tip:
  - If you invoke the shortcut a second time, it will search the project for chained method calls. Meaning that it could be a method on an object in the current scope or even calling a static method on a factory object. Pretty useful to autocomplete a Context.
Shortcut:
Ctrl+Shift+Space
Smart Type Completion
Smart Type Completion

Extract Method

Following in my streak of extract refactoring, here is the one to extract a code block in a new method.
This thing is extremely useful. Whenever you encounter a method that is starting to become a bit complex, you can use this to safely extract a portion in another method. I say safely because the IDE won't make a silly copy-paste mistake like we might do.
Additional tip:
  - Once you are in the extracting dialog, you can change the visibility of the method and the parameter names.
Shortcut (Menu):
Mac: Cmd+Alt+M
Windows/Linux: Ctrl+Alt+M
Extract Method
Extract Method

Compare With Branch (Git)

Assuming that your project is under Git, you can compare the current file or folder with another branch.
Pretty useful to get an idea of how much you have diverged from your main branch.
Shortcut :
  Menu : VCS -> Git -> Compare With Branch
  Find Actions: Compare With Branch
Compare With Branch (Git)
Compare With Branch (Git)

Column Selection

Enable column selections, also known as block selection.
Basically, if you select down, it will go down and not bother wrapping to the end of the line.
This will also put a cursor after each line of the block selection from where you can type.
Shortcut :
 Mouse: Alt+MouseDrag
 Mac : Cmd+Shift+8
 Windows/Linux: Shift+Alt+Insert
Column Selection

I want to credit this article  +Philippe Breault 

Get OUR Direct UPDATE
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.