Remembering and using shortcuts frequently will reduce your work time a lot, esp. for repetitive tasks. The following are the most useful shortcuts/hotkeys in Android Studio:
Table of Contents
- Alt + Left / Right: Switch to the previous/next tab
- Ctrl + Alt + Left / Right: Reversed version of Alt + Left / Right
- Ctrl +Left / Right: Navigate within code word-by-word
- F2: Go to the next syntax error
- Ctrl + F4 : Close tab. I don’t use this because I’m too familiar with Alt+F4 to close anything in Windows.
Search and Replace
- Double Shift: Multi-purpose searching. I use this shortcut a lot to search for files in res folder
- Ctrl + F : Find string in the current file
- Ctrl + R : Find and replace the string in the current file
- Ctrl + Shift + F : Find string in project files
Code / Comment
- Ctrl + D : Duplicate the current line of code
- Ctrl + Y : Remove the current line of code
- Ctrl + + / – : Expand / collapse code block
- Alt + Shift + Left Click: Place an extra cursor.
- Ctrl + Left Click: Go to the Class file of clicked object, method, or property.
- Ctrl + / : Comment / uncomment a line of code
- Ctrl + Shift + / : Comment / uncomment a block of code
- Ctrl + Alt + L : Reformat code
- Shift + F6: Refactor name replacement. This can be used in project view and code lines
- Ctrl + Alt + O: Optimize imports. It removes unused imports.
- Shift + F10 : Run selected build
- Shift + F9 : Debug selected build
- Ctrl + F2 : Stop build