11 Android Studio Shortcuts Every Android Developer Must Know


Ever Taken a Shortcut Before ?

This is how you may end up if you try and take a shortcut in real life, but it’s not true for the world of software !! Here you are encouraged to take shortcuts like auto complete, code generations, snippets and what not… A software engineer must know all the shortcuts of the IDE he is using and must have the environment BENT to his will. Given a keyboard he must be able to navigate through the IDE all around. This can increase his productivity manifolds and is also less distracting than shifting to a mouse/touchpad during typing.

As an Android Engineer I can only speak of Android Studio and here I will mention my top 11 most useful Android Studio Shortcuts ( Windows / Mac ):

1. Search Everywhere (Press Shift Twice / Press Shift Twice) :

This is the holy grail of the navigational shortcuts. It’s really simple. Search Android assets, navigate to the Gradle files, image resources, layouts, colors.xml and much more. There is nowhere you can’t go with the Double Shift shortcut.

Just press Shift twice and a hovering menu will po2.pup. Something like this :

As you can see I searched for “color” and it presented me with all the file with name color. This is my favorite one and I use it a lot in Android Studio.

2. Recently Opened Files :

More often than not, you’ll not be working with all the project files at once. You would be working on a specific module in a project and will be playing around some specific files of that module. The Android Studio has an option where you can browse the most recently opened files on the go. Just press CTRL + E  for windows and Command + E for mac and a list of recently opened files will popup.

Recently opened files shortcut
Recently opened files shortcut

3. Find Action :

So did you forgot what’s the shortcut for a replace action ? You forgot what’s the shortcut for a find action ? CTRL + SHIFT + A got you !! You can find actions such as Replace, Find, Run, Instant Run etc…

Here is a snippet :

Find Action Android Studio Shortcut
Find Action Android Studio Shortcut

I searched for the Run action and it gave me all the run options Android Studio has to offer like running the garbage collector and debug runner.

4. Search By Symbol Name :

This option is particularly useful if you want to search for some variable or method names. Many a times it so happens that you have declared a variable in some local code and forgot it’s origin, or you may want to find all the places it has been initialized or assigned some value. Well, android studio makes this very easy. Just press CTRL+ALT+SHIFT+N on Windows or Command+Option+O on Mac and type/guess a part of the variable name. Android studio will present you with a list of all possible options.

Find By Symbol Name Android Studio Shortcut
Find By Symbol Name Android Studio Shortcut

5. Generate Code (ALT+INS/Command+N) :

It can be time consuming to type out all the boilerplate code such as getters/setters in model classes, toString implementation, Parcelable Implementation and much more. Android Studio does all this for you. Press ALT+Insert on Windows or Command+N on Mac and android studio will list out all the options that are available such as override methods, implement interfaces, toString implementation etc…

Code Generation Android Studio Shortcut
Code Generation Android Studio Shortcut

6. Override Methods(CTRL+O/Command+O) :

When extending a Fragment or Activity class, you need to override certain methods such as onCreate and onCreateView. Apart from that you can also override lifecycle methods such as onPause, onResume, onDestroy. Android studio generates all this boilerplate code for you. Just press CTRL+O on Windows or Command+O on Mac and you’ll be presented with a list of methods that you can override.

Method Overriding Android Studio Shortcut
Method Overriding Android Studio Shortcut

You can see there are hundreds of methods which can be overridden and it is not possible to remember them all. So this shortcut comes in handy during development phase. You can also start typing a part of the name of method you want to override and the list will filter automagically.

7. Delete Line at Caret/Cursor (CTRL+Y/Command+Y):

If you want to delete the entire line, no need to select using a mouse or pressing backspace for the whole day. Just press CTRL+Y on Windows or Command+Backspace on Mac and you are good to go.

8. Basic Code Completion (CTRL+Space/Command+Space):

Forgot what all parameters your method requires ? Methods such as rawQuery (for SQLite) use many many parameters which are hard to remember. Here’s where Android Studio comes to the rescue. Just press CTRL+Space on Windows or Command+Space on Mac and you will be presented with a popup of all the variants of a method and the arguments that it expects.

Basic Completion Android Studio Shortcut
Basic Completion Android Studio Shortcut

9. Quick Documentation (CTRL+Q/Command+J):

This feature is also demonstrated in the previous image. Notice the popup box in grey. This is the documentation box. Just like that we can view the documentation of a particular method, including the class it extends from and some links to more details. Press CTRL+Q on Windows or Command+J on Mac and the popup box will show up. It requires an active internet connection.

Documentation Android Studio Shortcut
Documentation Android Studio Shortcut

10. Collapse/Expand Code Blocks (CTRL+- / Command+-):

Every developer is familiar with the callback hell, OnClickListeners, Dialog Click Listeners etc… These are anonymous classes that have multitudes of methods that need to be overridden. If you have a large codebase, then looking at such code can be daunting. Android Studio provides this option of collapsing all the blocks of code, just showing the method names so that you can find the method you are looking for easily, or just close out all other distractions and make your IDE look neat!!

To expand or collapse code blocks press CTRL+ +/- on Windows or Command + +/- on Mac. Have a look at the image below. The file looks so neat, showing only the method names :

Collapse/Expand Android Studio Shortcut
Collapse/Expand Android Studio Shortcut

11. Reformat Code (CTRL+ALT+L / Command+Option+L):

Again this is one of the most important shortcut that you can use. No need to manually indent all the nested if blocks or the for loops. Android Studio takes care of all the formatting. Just Press CTRL+ALT+L on Windows or Command+Option+L on Mac. The android studio will reformat all the code for you.
And the good part is that it works for XML layouts as well. It takes care of ordering of the xml attributes and indenting nested layouts in your code so that you focus more on coding and less on figuring out what is nested under what. So, this was my list of 11 most useful Android Studio Keyboard Shortcuts. These have helped me improve my productivity manifolds and hope it does for you as well.
Don’t forget to follow me on LinkedIn and Quora. If you have any questions or suggestions just drop a comment below and I’ll be happy to help.