Android Studio Shortcuts — How to manage the IDE without a mouse.

Max Hübscher
ProAndroidDev
Published in
8 min readJul 7, 2020

--

Photo by Troy Chen on Unsplash

To be more efficient and faster while developing and to stop searching for your mouse to navigate through your code, use shortcuts. This is one of the first lessons I have learned when I started programing years ago. I know there are a lot of articles about shortcuts out there, but I wanted to write one too 😉 And a lot of the shortcuts I am using regularly are most likely not mentioned in those articles.

As an Android developer I can only speak about the AndroidStudio IDE, but I think most of the shortcuts can be applied to all of the JetBrains IDEAs.

So here we go…

As a Mac user, I only know the shortcuts for the Mac keyboard (sorry for that), but you can simply find them in the Preferences > Keymap section of your IDE.
I will skip well-known shortcuts as auto completion, CMD + C or CMD + V. 🥴 But lets start with very similar one though …

1. Clipboard history _ CMD + SHIFT + V

Opens the history of your clipboard in a popup.

2. Last used files _ CMD + E

Opens a popup with your last visited files, excluding the one you are currently working on. And the last visited file is always preselected. So to jump to the previous file, you could easily hit CMD + E and ENTER.

Let’s go one step further.

3. Last used files with preview _ CMD + SHIFT + E

This combination shows you your last visited files as well, but also displays your last position in the code, previewing up to 5 lines of the file.

4. Search (All, Classes, Files, Symbols,Actions)

I think these are pretty basic shortcuts, but I noticed that they weren’t mentioned in some tutorial videos, so i wanted to include theme here for you 😉

4.1 Search everywhere _ hit SHIFT twice

4.2 Search classes _ CMD + O

4.3 File search _ CMD + SHIFT + O

4.4 Symbol search _ CMD + ALT + O

4.5 Action search _ CMD + SHIFT + A

All the mentioned shortcuts for search, are sharing one popup and you can navigate through them by the TAB key. I think all the tabs a very self-explanatory 😉

5. Find everywhere _ CMD + SHIFT + F

Find everywhere is Similar to the Search part and basically does a plain text search. You can narrow the search down to a module instead of the whole project or customize the search for example to use RegEx terms.

6. Run _ CTRL + R

Again a pretty basic shortcut, but still worth to mention 😉
CTRL + R Simply runs the project with the selected configuration on the last used device. I think this is almost the most used shortcut, I am at least using it on a daily bases.

7. Jump to last position _ CMD + ALT + <-/->

To navigate back and forth faster, hit CMD + ALT + ARROW_LEFT/ARROW_RIGHT. It will bring you to your last cursor position in your project.

8. Jump to last edit _ CMD + SHIFT + BACKSPACE

Sometimes you want to jump directly to your last edited position through various files and not the cursor positions. You can do so by hitting CMD + SHIFT + BACKSPACE.

9. Fast selection _ ALT + ARROW_UP

A shortcut which I heavily use is definitely ALT + ARROW_UP . It increases the selected context (or bracket content 🤷‍♀) by every ARROW_UP hit. E.g. first it selects the function parameter 1, then all parameters, then method body, then whole class and in the end the whole file.

See the selection expanding on every ARROW_UP
You can see the selection expanding with every ARROW_UP hit

10. Move functions _ CMD + SHIFT + ARROW_UP/DOWN

With the combination CMD + SHIFT + ARROW_UP/DOWN you can easily rearrange your code. As you can see in the image, you will be able to move functions and jump over others. To move line by line, go to the next shortcut.

11. Line by line _ ALT + SHIFT + ARROW_UP/DOWN

As mentioned before, you can easily move code line by line using ALT + SHIFT + ARROW_UP/DOWN.

12. Duplicate _ CMD + D

Again, a pretty basic one, but in my eyes worth mentioning. By using CMD + D on the line your cursor is located in at the moment, will be duplicated. You can also select a part, for example the method name, and hit CMD + D it will duplicate only that.

13. Multi-selection ❤️

The multi-Selection is one of my favorite features of the IDE and there are two ways to us it: Hold ALT + drag mouse courser (left mouse button clicked) over the lines you want select. Or go with the non-mouse option: Double tap ALT and on the second tap hold ALT down and use the arrow keys to select the lines you want.

14. Extract

With the following shortcuts you can extract selected code blocks to either a function, variable, property, parameter or functional parameter:

ALT + CMD + M _ method/function

ALT + CMD + V_ variable

ALT + CMD + F _ property (Kotlin)

ALT + CMD + P _ parameter

ALT + CMD + SHIFT + P _ functional parameter

15. Refactor _ CTRL + T

If you want to refactor a file or the code directly, you can use CTRL + T. This opens the refactor this menu. It will show you the extract shortcuts (as well) and even more. The rename option is for example always number one and preselected. In order to rename a class you can easily hit CTRL + T and 1 (or ENTER).

I know you could use SHIFT + F6, but I hate using the F-Keys, because Ihave the media-keys activated, so the F-Keys are hidden.
So in my case it would be
CTRL + FN + F6 and I don’t like one bit😅 🤷‍♀

16. Surround _ ALT + CMD + T

This shortcut opens the surround with menu depending on what you have selected. On a function call or variable it will give you (for example) some options like if/else or try/catch. If you select one or more functions, it will give you the options to add region or fold comments.

17. Show Member _ CMD + F12

I know I said, I hate using the F-keys, but sometimes they are actually not that bad 😬. CMD + F12 inside of a file or class will give you an overview of its members (properties, functions or inner classes)

18. Definition _ ALT + Space

Place your cursor on a method or property call and hit ALT + SPACE. It will open a popup with the definition of the selected item. This even works for view bindings or Kotlin synthetics.

19. Preview _ CMD + Y

Get a preview for usage of the class or method you have searched for it. You want to know where a class is used for example, you can check that with CMD + LeftMouse (I know we don’t want to use the mouse, but…) and then on the result popup, you can hit CMD + Y and you will get a preview as shown below. This works on many other views as well, like on the recent files popup (CMD + E).

Definition, where the class is used.

20. Parameters _ CMD + P

You know that feeling, when you are using a function and forgot about the parameter order or types. Don’t worry! You can easily use CMD + P inside the function brackets and it will show you a tooltip-like popup with name, type and order of parameters used.

(It also works with empty brackets 😉)

21. Git commands

The following git commands are very useful, if you don’t want to switch between your IDE and your git tool of choice. The integration is pretty good, so I don’t use any other program anymore (sometimes the terminal for more complicated stuff, but even that you could do with the IDE).

CMD + T _ git fetch

CMD + K _ git commit

CMD + SHIFT + K _ git push

CTRL + V _ version control popup

22. Close _ CMD + W

Last but not least, close tabs, sections or any windows easily with CMD + W

If you need help to memorise these or even more shortcuts and want to train your self to not use the mouse that often, you can use the IDE plugin Keypromoter. Every time you are hitting a button, the plugin will show you a notification with the corresponding shortcut and a counter how often you have used it in the past.

That’s it. Thanks for reading my first article. I hope there was at least one new shortcut for you 😉 If you have additional or mind blowing shortcuts, please share them in the comments below. If there are enough, I might write a second part 😄

If you like it, please leave some 👏 👏 👏

--

--