This is how you may end up if you try and take a shortcut in real life, but it’s not true for the world of software !! Here you are encouraged to take shortcuts like auto complete, code generations, snippets and what not… A software engineer must know all the shortcuts of the IDE he is using and must have the environment BENT to his will. Given a keyboard he must be able to navigate through the IDE all around. This can increase his productivity manifolds and is also less distracting than shifting to a mouse/touchpad during typing.
As an Android Engineer I can only speak of Android Studio and here I will mention my top 11 most useful Android Studio Shortcuts ( Windows / Mac ):
1. Search Everywhere (Press Shift Twice / Press Shift Twice) :
Just press Shift twice and a hovering menu will po2.pup. Something like this :
As you can see I searched for “color” and it presented me with all the file with name color. This is my favorite one and I use it a lot in Android Studio.
2. Recently Opened Files :
More often than not, you’ll not be working with all the project files at once. You would be working on a specific module in a project and will be playing around some specific files of that module. The Android Studio has an option where you can browse the most recently opened files on the go. Just press CTRL + E for windows and Command + E for mac and a list of recently opened files will popup.
3. Find Action :
Here is a snippet :
4. Search By Symbol Name :
This option is particularly useful if you want to search for some variable or method names. Many a times it so happens that you have declared a variable in some local code and forgot it’s origin, or you may want to find all the places it has been initialized or assigned some value. Well, android studio makes this very easy. Just press CTRL+ALT+SHIFT+N on Windows or Command+Option+O on Mac and type/guess a part of the variable name. Android studio will present you with a list of all possible options.
5. Generate Code (ALT+INS/Command+N) :
6. Override Methods(CTRL+O/Command+O) :
7. Delete Line at Caret/Cursor (CTRL+Y/Command+Y):
If you want to delete the entire line, no need to select using a mouse or pressing backspace for the whole day. Just press CTRL+Y on Windows or Command+Backspace on Mac and you are good to go.
8. Basic Code Completion (CTRL+Space/Command+Space):
Forgot what all parameters your method requires ? Methods such as rawQuery (for SQLite) use many many parameters which are hard to remember. Here’s where Android Studio comes to the rescue. Just press CTRL+Space on Windows or Command+Space on Mac and you will be presented with a popup of all the variants of a method and the arguments that it expects.
9. Quick Documentation (CTRL+Q/Command+J):
This feature is also demonstrated in the previous image. Notice the popup box in grey. This is the documentation box. Just like that we can view the documentation of a particular method, including the class it extends from and some links to more details. Press CTRL+Q on Windows or Command+J on Mac and the popup box will show up. It requires an active internet connection.
10. Collapse/Expand Code Blocks (CTRL+- / Command+-):
Every developer is familiar with the callback hell, OnClickListeners, Dialog Click Listeners etc… These are anonymous classes that have multitudes of methods that need to be overridden. If you have a large codebase, then looking at such code can be daunting. Android Studio provides this option of collapsing all the blocks of code, just showing the method names so that you can find the method you are looking for easily, or just close out all other distractions and make your IDE look neat!!
To expand or collapse code blocks press CTRL+ +/- on Windows or Command + +/- on Mac. Have a look at the image below. The file looks so neat, showing only the method names :
11. Reformat Code (CTRL+ALT+L / Command+Option+L):
And the good part is that it works for XML layouts as well. It takes care of ordering of the xml attributes and indenting nested layouts in your code so that you focus more on coding and less on figuring out what is nested under what.
Don’t forget to follow me on LinkedIn and Quora. If you have any questions or suggestions just drop a comment below and I’ll be happy to help.