Essential Android Studio Shortcuts: Getting around Android Studio
There are no shortcuts to success but getting around Android Studio with shortcuts makes developing your app easier and thereby leading to your success. So, without further adieu, let us look into some of the most useful shortcuts in Android Studio:
1. Basic code completion
Ctrl + Space
On using this shortcut, you get a list of options that you can choose from to complete your code. You can also type the first letters of a CamelCase function and it will automatically give you a list of options based on that a shown below
2. Find Usages
Option(alt) + F7
Find usages of a file in your project
3. Rename
Shift + F6
A simple rename goes a long way. Android Studio helps you do a refactor throughout your code when you use the Rename option. So if you want to just change the name of a class, a variable or even the entire package, you can do that using this function.
4. Generate code
Cmd + N – Mac
Alt + Ins – Windows
This gives you a list of getters, setters, constructors, hashCode/equals, toString, new file, new class and few other options depending on the class that use this in.
5. Override Methods
Ctrl + O
When a class is extended from another class, it inherits all its methods (functions). you can get a list of the available methods that can be overridden by using this shortcut.
6. Reformat Code
Cmd + Option + L
Control + Alt + L
Occasionally when coding in Java, we don’t pay mind to the formatting of code, whether we are using tab spacing or lining the opening and closing braces in the same line. You need not worry about code formatting much now as you can use this shortcut.
7. Go to Declaration
Cmd + B/Cmd + Click
Ctrl + B/Ctrl + Click
Use this shortcut to go to the declaration of a function, class, variable or file. This really helps you understand the declaration or origin of code in the app. You can use this to also jump to XML files used in the Java code.
8. Comment/uncomment with line comment
Cmd + /
Ctrl + /
Used some line of code for testing, maybe for logging. Just use this this shortcut to comment it out. Comments are useful for explaining what is going on in the code and sometimes you can use it to remove some part of code that you can later euse.
Common Shortcuts
- Quit Android Studio
Cmd + Q/Ctrl + Q - Copy – You can copy an entire line by placing the cursor in that line & using this shortcut
Cmd + C/Ctrl + C - Cut – You can cut an entire line by placing the cursor in that line & using this shortcut
Cmd + X/Ctrl + X - Paste
Cmd + V/Ctrl + V - Undo
Cmd + Z/Ctrl + Z - Redo
Cmd + Shift + Z/Ctrl + Shift + Z - Find
Cmd + F/Ctrl + F - Replace
Cmd + R/Ctrl + R
You can find the entire list of available shortcuts in the official Android Studio user guide. You can also access the shortcuts in Android studio by clicking File > Settings > Keymap (on Mac, Android Studio > Preferences > Keymap). All the shortcuts are also shown again the options in the menu. So when using the menu options, check out the shortcuts against it.