Top 10 Android Studio Keyboard Shortcuts
Consistently using keyboard shortcuts can save you a lot of time when it comes to programming. A few seconds saved each time adds up when you’re doing it 100+ times a day. Properly using keyboard shortcuts is an easy productivity hack. Memorizing and keeping a tab of them all in your head can be an exhausting task though. So I’ve compiled a list of the top 10 keyboard shortcuts I use with Android Studio for people who want to quickly and easily improve their productivity in this way.
*I excluded the obvious ones everyone already knows like copy, paste, cut, etc.
- Ctrl + R
Replaces entered text in first input with entered text in 2nd input. Provides option to replace only selected case, or all cases. Usefully when you need to rename a method or property multiple places in a file.
- Alt + Insert
Generates code. If you’re manually writing getters and setters for your object properties, this will save you a ton of time. There are a few operations that the code generator can perform, but auto generation of getters & setters is the most useful.
- Ctrl + Y
Deletes line which the cursor is currently on. Simple and faster than highlighting the entire line every time.
- Ctrl + Alt + H
Opens selected method call hierarchy. It’s very helpful to see a visual hierarchy of all the locations where your selected method is being called from. This will save you a lot of time if you’re manually searching and walking up your method call stack.
- Ctrl + Alt + T
Surround selected code block. Use this to surround your code with conditionals, try/ catch statements, etc. I was so excited when I figured this out. I can’t even imagine how many times I used to manually type out an if statement, paste my code block in, and close the if statement. This is much faster.
- Ctrl + Shift + +/-
Expand or collapse all method definitions in a file. I do this as much as possible because it’s insanely annoying to be searching for a piece of code while scrolling through hundreds of lines of irrelevant code just to get to a certain spot in the file. It’s also much easier to jump around and figure out what’s going on in a class when your methods are collapsed.
- Shift 2x
Search project. Simple and self explanatory, but will save you a ton of time if you’re going to Edit -> Find whenever you search. Or if you’re not using the search feature at all!
- Ctrl + Shift + /
Commented selected code block. Much easier than manually typing /* */ before and after every code block you need to comment.
- Shift + Tab
Unindent selected code block. How annoying is it when you paste some code in, and it’s not formatted properly, or indented too far.
- Alt + F8
Evaluate expression. This is incredibly useful when you’re debugging and want to evaluate an expression. If you’re doing log statements or something else currently to check values.. You’ll thank me later.
Bonus: F8, F9, Ctrl + Shift + F8
These are shortcuts used when debugging. There are more than these, but these are what I most frequently use. I thought they were worth mentioning separately since they can all be grouped together.
Of course there are many more shortcuts I left out which are useful, but these are the top 10 shortcuts I find most useful on a daily basis. Think I left one out? Leave me a comment below!