Few weeks ago I was taking part in recruitment process. During technical part I was asked to enable Presentation Assistant https://plugins.jetbrains.com/plugin/7345-presentation-assistant which shows used keyboard shortcuts. I thought that this is good scenario for short blog post.
Today, I will show you my most used 10 Android studio keyboard shortcuts (and probably any IDE from JetBrains). I will split my list in two parts, from my point of view, more basic ones and more advanced ones. Ordering is random. Shortcuts are from macOS keymap.
Basic shortcuts
#1 Go to declaration/usage: Cmd+B
Switching between declaration and usage. Pretty self-explanatory.
#2 Find a class/file by name: Cmd+O
If we know class name, just hit command, type class name and enter. The same goes with file, which can be performed via doing the same command and clicking tab button. So we don’t have to remember another shortcut.
#3 Switch between last files: Cmd+E
As I work in customized Android Studio interface, I like to work without any tabs, only one file opened at a time. So I don’t have any tabs to click on. Changing files via keyboard is the only way to go.
#4 Optimize imports: Ctrl+Alt+O
Remove unused imports. Don’t clutter your file with redundant lines.
#5 Reformat code: Cmd+Alt+L
If we agreed in our team on code style, we should follow it. It can also be done when doing commit via UI but I like to keep my code formatted properly all the time – it’s more readable for me.
Advanced shortcuts
#1 Show Git annotations: Cmd+Shift+S
To see who, when and what committed. This is my custom shortcut.
#2 Extract method: Cmd+Alt+M
Making code pieces reusable and small with single responsibility.
#3 Go to line: Cmd+L
While doing review, checking line in Pull Request and going straight to exact line in code.
#4 Search everywhere: Cmd+Shift+F
For example, I don’t remember how some Fragment is called but I do remember string that is used there.
#5 Search action: Cmd+Shift+A
Really helpful when doing changes in Gradle files, fast shortcut to show actions popup, type ‘sync gradle’ and hit enter – done 🙂
This is my personal list of keyboard shortcuts i cannot live without during development in Android Studio. Must have for me! If you have any custom shortcuts like me, I will suggest exporting your config from Android Studio 🙂