Top 3 Android Studio shortcuts - Eduard

Datetime:2016-08-22 23:17:56         Topic: Android Studio          Share        Original >>
Here to See The Original Article!!!

Everyone likes to increase their productivity and everyone has their own favourite productivity hacks, but not everyone agrees! In this blog, Eduard will talk about his top three Android Studio shortcuts and how they're better than the rest.

Before actually jumping into the shortcuts, let me share with you a couple of plugins that will help you and your pairing peer learn more shortcuts, resulting in an increased productivity!

  • Key promoter – Show the associated keyboard shortcut for actions done with the mouse.
  • Presentation Assistant – Shows the shortcut used in a manner similar to a Toast.

Show intention actions

⌥⏎ (Mac) | Alt+Enter (Win/Linux)

This might be the most used shortcut in IntelliJ / Android Studio (at least by me). It's highly context-aware, giving you a wide range of helpful options, from quick fixes to compilation errors, to improvement suggestions of your code.

I could give you a ton of examples of situations where this shortcut might be used, but I will name just a few of my favorites: adding a final field as a constructor parameter or binding a constructor parameter to a field, flip , , invert if condition.

Don't be afraid to use it, and try it everywhere, you will be surprised what kind of suggestions it might give you.

Add selection for next occurrence

⌃G (Mac) | Alt+J (Win/Linux)

Given that you have selected something, it will add the next occurrence to the selection, also adding a cursor there, similar to how Sublime's multiple selection works.

This is particularly useful when you want to apply collectively an operation to similar elements in a group. I mostly use it to alter field's modifiers and to split long lines in situations such as method declarations or calls with many parameters.

If you go too far, you can use "Unselect occurrence" – ⌃⇧G (Mac) | Alt+Shift+J (Win/Linux) – to step backwards.

Completion → SmartType

⌃⇧Space (Mac) | Ctrl+Shift+Space (Win/Linux)

Some of my colleagues were mindblown by the power of this shortcut. Basically, it's similar to basic code completion ( ⌃Space on Mac, Ctrl+Space on Win/Linux), but it filters the list of results based on the type of the expected object. This will save you time showing only relevant suggestions, instead of going through an exhaustive list of possibilities.

Even more, if you press the key combination a second time, it will go recursively one level down, giving chained expressions as suggestions. Also, if there is only one possible match, it will complete the statement with it, meaning that it will put the semicolon for you.

Additionally, if you are in a method call, and in that context there are variables matching all the expected types and/or names of the method's parameters, it might give you a suggestion with all the required parameters at once. Pretty neat, isn't it?

Happy and productive programming!


Put your ads here, just $200 per month.