I’m going to share some useful Android Studio shortcuts which help me a lot when I’m writing code. Some of the shortcuts you might know, but some of them I think most of developers don’t even know them… I’m serious because when I knew live templates and postfix completion, I was like… what? I don’t even know they have shortcuts this powerful. Taking advantages of shortcuts can help you write code faster and more efficient. The shortcuts in this post will not only contain general keyboard shortcuts but also live templates and postfix completions. I found these shortcuts really useful from the official intellij docs and an Android Dev Summit 2015 video. So I will share shortcuts in three parts, general shortcuts, live templates, and postfix completions.

In this post, the keyboard shortcuts are for MAC users. If you are Windows or Linux users, in general you can replace CMD to Ctrl. Or you can checkout the preference in Android Studio. 

General Shortcuts

  • Navigate to next/previous tab

Previous tab: CMD + Shift + [

Next tab: CMD + Shift + ]

  • Navigate to next/previous edited location

Previous location: CMD + Shift + ←

Next location: CMD + Shift + →

  • Switcher

Alt + Tab

  • Switch to specific section

CMD + {Number} 

For example, CMD + 1 to project section. As you can see, on the left hand corner of the GIF below.

Respectively, CMD + 7 to the structure section, the tab which is under the project tab as we mentioned.

  • Maximize editor

CMD + Shift + F12

If you are using macbook, don’t forget to press “fn” key together with the key combination.

  • Search everywhere

Double click Shift

This is really useful when you are searching something but you don’t wanna just search for only one type of files or whatever, you can just use this to quickly locate the thing you are searching.

  • Show class structure

CMD + F12 (and don’t forget fn if you use macbook)

  • Find actions

CMD + Shift + A

I highly recommend this shortcut, THIS IS EXETREMELY USEFUL! Why? Because you probably won’t remember all shortcuts even for those commands doesn’t have shortcuts. This shortcut can help us to use those commands without having to remember shortcuts. And to be honest, this one is my favorite shortcut. :D

  • Show usages

Alt + F7

  • Go into class/method

F4

It’s useful when you are tracing code…

  • Go into implementations

CMD + Alt + B

  • Extract…

I always use double shift to find this one… It’s useful when you finish writing implementation and want to extract interface from it.

  • Surround with

CMD + Alt + T

  • Extend selection

Alt + ↑ and Alt + ↓

Before I know this one, I use mouse to select words or use Shift. Right now, I don’t need it because this one is way more useful.

  • Move lines

CMD + Shift + ↑ or CMD + Shift + ↓

  • Multicursor

Alt + Shift + left mouse click

  • Reformat code

CMD + Alt + L

  • Error Fix

Alt + Enter

  • Upper/lower case

CMD + Shift + U

Live Templates

  • Log Tag

type “logt”, then press Tab

  • Logging

Type logd or logw and so on… then press Tab

  • Find View by Id

Type fbc, then press Tab

  • New Instance

Type newInstance, then press Tab

  • Visibility

Type visible, then press Tab

  • Toast

Type Toast, then press Tab

  • XML

For XML, Android Studio actually provide some templates for users to write code faster. For instance, “lwh” stands for “ android:layout_width=”match_parent” “. If you want to learn how to use them, please check out the preference of Android Studio, it has Live Templates section for you to set your templates.

Postfix Completion

  • Cast

Cast your object faster

  • if & else

  • Field

  • For

  • Null Check

  • Try & Catch

Others

  • Key Prompter

This is a IntelliJ plugin to remind you keyboard shortcuts. Every time you use mouse instead of keyboard shortcuts, it immediately prompt a small window to let you know the shortcut. For some people this plugin might be annoying, but for me, I think this is a tool to help me memorize shortcuts, and my coding efficiency might be better. I firstly heard about this plugin from Fragmented Android podcast, and I immediately download this plugin to my Android Studio… By the way, the podcast is awesome… I think Android developers should listen. I’m a big fan of the podcast😂