Top 17 Android Studio Shortcuts

T

A good developer knows how to write an efficient code but an awesome developer knows how to write that efficient code more efficiently.

Today in this post, I will list some important and useful Android Studio shortcuts which, when used will save a significant amount of your time. I use these shortcuts and hence know the importance and the amount of time that it saves.

And more importantly, they just let you code consistently without any breach of moving to your touchpad and looking for that option. All that you would need to use while coding will be your fingers and a few combinations of keys. And I can assure you that you will enjoy coding your app using these cool shortcuts.

Live Templates

Windows/Linux: Ctrl + J

macOS: CMD + J

With the help of Live Templates, you can easily eliminate writing boilerplate code by using shortcuts for specific things.

On using the above shortcut, you will see a list of all the live templates you can use and by clicking on any of them, the IDE will write the code for the functionality shown. And when you know the names of these live templates, you can just write the name and press tab and see the magic.

For example, the code for the live template for showing a toast message is “Toast”. Hence write Toast and press tab and voila! You didn’t have to write the entire line for creating a toast message.

You can even create your own live template by navigating to File > Setting > Editor > Code Style > Live Templates

Search for Command

Windows/Linux: Ctrl + Shift + A

macOS: Cmd + Shift + A

Using the above shortcut you can create a lot of things quickly without wasting your precious time.

For example, if you want to create a basic Java Activity, press Cmd + Shift + A in mac and then type “basic activity” and select the option that shows and press enter. A prompt will open asking you to name the activity and a new Java file will be created.

Multicursor

Windows/Linux: Alt + J

macOS: Ctrl + G

Using the multicursor shortcut, you can select a particular block or line of code and on pressing Ctrl + G on mac, it will select the next iteration where that code appears and again pressing the shortcut, you can further continue the selection as shown below. This can be useful when you want to rename all the iterations of a particular variable or other code.

Open a Class

Windows/Linux: Ctrl + N

macOS: Cmd + N

Use this shortcut and start typing any class name. It will show you the list of classes, select the one you intend to open and press enter.

Open any File

Windows/Linux: Ctrl + Shift + N

macOS: Cmd + Shift + N

Use this shortcut and start typing any file name. It will show you the list of filenames, select the one you intend to open and press enter.

Go to declaration

Windows/Linux: Ctrl + B

macOS: Cmd + B

Place the cursor on the variable and use this shortcut to see its declaration. Mostly, I use this when I want to change the data type of the declared variable or modify the structure of the class.

Move between tabs

Windows/Linux: Alt + Left Arrow Key/Right Arrow Key

macOS: Cmd + Shift + [ / ]

Use this shortcut to navigate between the open tabs in Android Studio. Just remember me and this shortcut when you feel lost among the sea of tabs open in front of you.

Move between design/text tabs in the layout view

Windows/Linux: Alt + Shift + Left Arrow Key/Right Arrow Key

macOS: Ctrl + Shift + Left Arrow Key/Right Arrow Key

Use this shortcut to navigate between design and text tabs in layout view while editing XML files. This is probably the most used and time-saving shortcut when you are designing a layout.

Close a current tab

Windows/Linux: Ctrl + F4

macOS: Cmd + W

Use this shortcut to close a currently opened tab in Android Studio. It will close the tab that is currently selected.

Format/Indent the Code

Windows/Linux: Ctrl + Alt + L

macOS: Cmd + Option + L

Use this shortcut to auto-indent or format the entire code in a given file.

Smart Code Completion

Windows/Linux: Ctrl + Shift + Space

macOS: Ctrl + Shift + Space

Use this shortcut to get a suggestion regarding the naming of your variables and methods.

Find

Windows/Linux: Ctrl + F

macOS: Cmd + F

Use this shortcut to find anything in a given file. Nothing new but worth mentioning. 😐

Find and Replace

Windows/Linux: Ctrl + R

macOS: Cmd + R

Use this shortcut to find and replace anything in a given file. Of course, you know it but one ought not to leave anything out.

Move hardcoded Strings to Resources

Windows/Linux: Alt + Enter

macOS: Option + Return

Use this shortcut to convert and save your hardcoded strings into strings.xml file of resources folder.

Build and Run

Windows/Linux: Shift + F10

macOS: Ctrl + R

Use this shortcut to build your project and run it on the device or emulator.

Search Anything

Windows/Linux: Press Shift twice

macOS: Press Shift twice

Use this shortcut to search anything related to your project in Android Studio.

Generate Code

Windows/Linux: Alt + Insert

macOS: Cmd + N

Use this shortcut to generate code like getters, setters, constructors, etc.

So, friends, this includes almost all most prominently used shortcuts in Android Studio.

Feel free to add to the list. If I have forgotten some important ones, I’ll definitely update this list.

Happy Coding 🙂

About the author

Editorial Staff

Recommended Host

Siteground hosting Covid19 offers

Top Posts