Top Android Studio ShortCut Commands | AndroidMonks

Android Studio ShortCut | Develop Faster

If you have been following my articles over the years, I advocate on developing a best practice while you code. Using Shortcut is a very good way to improve your code. Like any Art, programming also is a way of expressing your ideas. It could be as small as creating your custom shortcuts to develop your style of writing a code, or even could be your way of naming a function or even favoring one design pattern to another.

Also Read  Activities in Android - Tutorial | AndroidMonks

In this article, I will be quickly summarising my most useful and top Android Studio Shortcuts which you will have to make it a part of your coding style.

YOU ARE YOUR BOSS
I agree to have my personal information transfered to MailChimp ( more information )
Join over 5.000 visitors who are receiving our free content and learn how to program with Android. The growth of Android is estimated to reach a whooping 83% by 2020. Hop on the train and start making money!
We hate spam. Your email address will not be sold or shared with anyone else.

It takes an average developer close to approximately 8 days in a year(Assuming 48-50 hour work week), in switching between a mouse and a keyboard, the shortcuts are definitely going to cut your development time. You can scroll down now to grab the Cheat Sheet PDF, or stay on and read every Shortcut with its related Action.

The below Android Shortcut keys are compiled as “most used/useful”. There are several more keys that may be of use to you. I will put all of them at the end of this post.

General Shortcut Keys

Switch between tabs and tool window

This one is very useful since you do not need to switch from your mouse to keyboard to switch between files in your project.

For Windows: Control + Tab

For MAC: Control + Tab

Switch files
Switch files
Add to favorites

This is another frequently used general shortcut. Helps you to add a file or class to your favorites, which will, in turn, help you to refer, in some other project or scenario. Check the shortcut key combination below.

Windows/Ubuntu: Alt + Shift + F

Mac: Option + Shift + F

Add to favorites
Add to favorites
Save All

Everyone might already be doing this. The shortcut for this action is,

Windows/Ubuntu: Control+S

Mac: Command+S

Inspect Current File with current Profile

If you have the habit of checking your File using lint(Most of the developers don’t, but it is a very good practice to check), you can use the below Key combination.

Windows/Ubuntu: Alt + Shift + I

Mac: Option + Shift + I

Lint Check
Lint Check
Navigation & Searching
Replace

This can be useful when you have to quickly replace method/variable name in the given file. Make sure to be careful when doing so.

Windows/Ubuntu: Control + R

Mac: Command + R

Replace bar pops up
Replace bar pops up
Find class

Find class is particularly useful in bigger projects with lots of different files. A quick search to go to the Class can save time searching for it in every file.

Class search
Class search

Windows/Mac: Control + N

Ubuntu: Command + O

Jump to source

Jump to the source has to be the best search shortcut in any ide, it saves a ton of time switching between the implementation and the source. You can find the source of anything using the command shortcut.

Windows/Ubuntu: Control + Enter

Mac: Command + Down Arrow

 

Jump to source
Jump to source

 

Open type hierarchy

This is useful to see the type of the method/variable and which class uses it. The shortcut for this is,

Windows/Ubuntu: Control + H

Mac:Control + H

For an Integer class
For a Integer class
For a custom class

 

Open method hierarchy

As the name suggests, it shows the hierarchy of methods used in the class. Works only on the methods.

Method heirarchy of onCreate method
Method hierarchy of onCreate method

Window/Ubuntu: Control + Shift + H

Mac: Command + Shift + H

Open call hierarchy

This shortcut shows all the places where a specific variable or method is called from. This open call hierarchy can be useful to debug errors easily

Windows/Ubuntu: Control + Alt + H

Mac: Control + Option + H

Open call hierarchy
Open call hierarchy
Go to line

Opens up a dialog to enter the line number to jump to. Helpful in larger files and also reduces time in scrolling.

Windows/Ubuntu: Control + G

Mac: Command + L

Search Every Where

Search everywhere in the project using the command below.

Windows/Ubuntu: Shift+Shift

Mac: Shift+Shift

Find next

Goes to next search item

Windows/Ubuntu: Shift+F3

Mac: Command + G

Find previous

Goes to the previous search item

Windows/Ubuntu: Shift + F3

Mac: Command + Shift + G

Writing code

Generate code

This is the handiest shortcut in Android studio. It takes care of generating lot of static code for you. Getters, Setters, Constructors, toString methods etc in a press of command. The shortcut for creating that is,

Windows/Ubuntu: Alt + Insert

Mac: Command + N

Getters, setters, code generator
Getters, setters, code generator
Basic code completion

Handy when you want to complete a line of code. The general code completion, completes a variable/method names by itself and cannot do anything more. The command for that is,

Windows/Ubuntu: Control + Space

Mac: Control + Space

Quick Code completion
Quick Code completion
Smart Code Completion

Smart code completion is useful when you need code completion with respect to the file or class you are working on. A basic code completion does a static job of filling up the rest of the code with what the general implementation can be, check the example below to understand clearly.

Windows/Ubuntu: Control + Shift + Space

Mac: Control + Shift + Space

We will take the same scenario of implementing the Integer above. The class that I am working on has a method called getItemCount() which is in respect to that particular class only. The smart code completion does this,

Smart Code Completion
Smart Code Completion
Surround with (if…else / try…catch / etc.)

Another useful shortcut to create an immediate block around a piece of code, a need for an if/else block or an exception expression which needs a try..catch you can use this shortcut command.

Windows/Ubuntu: Control + Alt + T

Mac: Command + Option + T

Surround with blocks
Surround with blocks
Move to code block start

Helps you jump directly to the start of the code block

Windows/Ubuntu: Control + [

Mac: Option + Command + [

Move to code block end

Helps you jump directly to the end of the code block

Windows/Ubuntu: Control + ]

Mac: Option + Command + ]

Select to the code block start

Helps to select to the code block start

Windows/Ubuntu: Control + Shift + [

Mac: Option + Command + Shift + [

Select to the code block end

Helps to select to the end of the code block

Windows/Ubuntu: Control + Shift + ]

Mac: Option + Command + Shift + ]

Comment Specific

The single and multi line comments are very helpful when it comes to shortcut codes. I would highly recommend using comments in your coding practice to generate much better readable code. The shortcut for the comment operation is given below.

Comment/uncomment with line comment

Windows/Ubuntu: Control + /

Mac: Command + /

Comment/uncomment with block comment

Windows/Ubuntu: Control + Shift + /

Mac: Command + Shift + /

Build and Run

Build

Windows/Ubuntu: Control + F9

Mac: Command + F9

Build and run

Windows/Ubuntu: Shift + F10

Mac: Control + R

Apply changes – Instant Run

Windows/Ubuntu: Control + F10

Mac: Control + Command + R

Debugging

Debugging is another important facet of programming, as much you learn to code, you learn to understand what the compiler says in terms of a mistake being created. You can have this shortcuts handy while debugging your program.

Debug

Lets you do a debug through an interface. Once you get an error, you can use this option to run the debug application.

Windows/Ubuntu: Shift + F9

Mac: Control + D

Debug Application option
Debug Application option
Toggle breakpoint

Helps you toggle a breakpoint. Breakpoints are artificial stops in the program which can help you know if a program hits it or not (In terms of debugging a broken program with errors)

Windows/Ubuntu: Control + F8

Mac: Command + F8

Breakpoints
Breakpoints
View breakpoints

Helps you view the breakpoints.

Windows/Ubuntu: Control + Shift + F8

Mac: Command + Shift + F8

Smart step into/Step out

Smart step into will help you to jump into a call(In terms of hitting a breakpoint). If there are chained calls, it will ask which method to step into. See the example below.

Windows/Ubuntu: Shift + F7 / Shift + F8

Mac: Shift + F7 / Shift + F8

Animated Photo
Source: Philippe Breault(Google+)

Version control

If you are a using version control/VCS, you can find some useful shortcuts to commit/push your code like.

Commit project to VCS

Windows/Ubuntu: Control + K

Mac: Command + K

Open VCS popup

Opens up the VCS popup like below. A lot of operations can be performed.

Windows/Ubuntu: Alt + ` (backquote)

Mac: Control + V

CVS Version control
VCS Version control

 

This is an exhaustive list of all the shortcuts available in Android Studio

Since you had the patience to scroll till the end. Find the PDF of the list below.

Drop in Any Comments you have in the comment section.

“Learn and Be Curious”

Leave a Comment

Your email address will not be published. Required fields are marked *