- Android Studio Shortcuts: How to Boost Your Productivity
- The Most Famous
- The Most Underrated
- Selection Tool
- Bookmarks and Favorites
- Favorites
- Bookmarks
- Mnemonic Bookmarks
- Surround With
- Key Promoter Plugin
- The Hidden Power of Double Shift
- Conclusion
- Android Studio Shortcuts You Need the Most
- Navigation Shortcuts
- Programming Shortcuts
- General Shortcuts
- Popular Articles
- Comments on «Android Studio Shortcuts You Need the Most»
- 11 Android Studio Shortcuts every Android Developer must know
Android Studio Shortcuts: How to Boost Your Productivity
Using the proper shortcuts when programming and refactoring can not only make a difference in terms of time, but also drastically increase your productivity. IntelliJ IDEA is a great IDE (bye bye Eclipse) and offers a set of shortcuts that help streamline debugging and development operations. Android Studio is the official IDE for Android and is based on IntelliJ IDEA.
The Most Famous
Let’s start with some of the most well-known and regularly used shortcuts for some common operations in Android Studio. I expect every Android developer uses these on a daily basis, so I won’t go into too much detail.
The following shortcuts are set by default on Mac using the keymap option Mac OS X 10.5+ . The keymap option can be changed in Android → Preferences → Keymap . You can also hit SHIFT twice and type keymap to change the option (I’ll talk more about this later).
Reformat code → CMD + ALT + L Optimize imports → CTRL + ALT + O Rename → SHIFT + F6 Find usages → ALT + F7 Find in path → CMD + SHIFT + F Run → CTRL + R
The Most Underrated
Let’s continue with something more interesting.
Selection Tool
Android Studio (so IntelliJ) has a very smart selection tool. It can be activated pressing ALT + UP , and the selection tool will automatically select the whole statement/expression/line you’re looking at.
If the selection needs to be expanded, just press ALT + UP again until the desired selection is reached. Did you select too much? Don’t worry; pressing ALT + DOWN will revert the selection tool to the previous state.
Bookmarks and Favorites
For large projects, bookmarks and favorites are a lifesaver, as they offer the ability to mark specific classes or specific lines of code and easily access them later.
By default, bookmarks and favorites are located in the favorites menu in the tool buttons on the left.
The Favorites menu can also be accessed via shortcut by using CMD + 2 .
Favorites
To add a class to the favorites, use ALT + SHIFT + F . To add a class to a new favorites list, use ALT + SHIFT + F , and then 2 , and a pop-up will ask for the new list name.
Bookmarks
To bookmark a specific line of code, use F3 . There’s no limit to the number of bookmarks that can be added.
Using CMD + F3 will open another view showing all the bookmarks available on the left and the ability to navigate the code on the right.
If a bookmark needs some notes, a small description can be added by pressing CMD + RETURN .
Mnemonic Bookmarks
Mnemonic bookmarks are like ordinary bookmarks, but they allow for even quicker access.
To set a mnemonic bookmark, simply go to the line of code you want to bookmark and press ALT + F3 . A small window showing the available quick access keys will pop up. Once the quick access key has been chosen (e.g. 1 ), it’s easy to navigate to that bookmark by using CTRL + key (e.g. CTRL + 1 ).
Surround With
An invaluable shortcut during refactor operations is ALT + CMD + T . It will surround the selected text with something, e.g. try/catch , an if statement, or simple brackets. A small menu will then present some options to choose from, and they can be clicked or selected via keyboard.
For instance, to surround a piece of text with curly braces, select the text and press ALT + CMD + T , followed by A .
If the text needs to be surrounded with something more complex, a live template can always be set.
Key Promoter Plugin
For those who decide to carry on with the rocky road of mastering Android Studio shortcuts, Key Promoter is a plugin that will “help” you learn a shortcut every time an operation has been selected using the mouse.
The plugin does this by displaying big pop-ups showing the missed shortcut and the number of times the operation has been called without using the keyboard shortcut. On the tool buttons on the right, Key Promoter offers a small menu that will show the number of missed shortcuts in order of importance.
The Hidden Power of Double Shift
Another way to learn a shortcut is by searching for it. Hitting SHIFT twice will open the general search bar, which can be used to look up classes, files, symbols, and any other action with a shortcut.
General search can be also used to navigate the tool windows of Android Studio. For instance, to open Layout Inspector, simply hit SHIFT twice and type layout inspector .
Conclusion
Learning to navigate an environment and its shortcuts is never easy, but hopefully this primer on Android Studio shortcuts is a good starting point that will lead to increased productivity.
For a comprehensive list of shortcuts, JetBrains has a PDF available for download here.
Источник
Android Studio Shortcuts You Need the Most
Switching from Eclipse to Android Studio for Android development requires some adjustments. Android Studio is based on IntelliJ IDEA and for those new to this IDE, this refcard article will be of help.
I have got used to Eclipse and boosted my productivity by using the Eclipse shortcuts regularly. Mouse is a productivity killer, mouse makes us lame. We need shortcuts to be on top. Following are most essential Android Studio shortcuts we need.
Download this Essential Android Studio Shortcuts list as a printable PDF for quick reference.
Navigation Shortcuts
Shortcut Description | Android Studio Shortcut |
---|---|
Go to class | Ctrl + N |
Go to file | Ctrl + Shift + N |
Navigate open tabs | ALT + Left-Arrow; ALT + Right-Arrow |
Lookup recent files | CTRL + E |
Go to line | CTRL + G |
Navigate to last edit location | CTRL + SHIFT + BACKSPACE |
Go to declaration | CTRL + B |
Go to implementation | CTRL + ALT + B |
Go to source | F4 |
Go to super Class | CTRL + U |
Show Call hierarchy | Ctrl + Alt + H |
Search in path/project | CTRL + SHIFT + F |
Programming Shortcuts
Shortcut Description | Android Studio Shortcut |
---|---|
Reformat code | CTRL + ALT + L |
Optimize imports | CTRL + ALT + O |
Code Completion | CTRL + SPACE |
Issue quick fix | ALT + ENTER |
Surround code block | CTRL + ALT + T |
Rename and refactor | Shift + F6 |
Line Comment or Uncomment | CTRL + / |
Block Comment or Uncomment | CTRL + SHIFT + / |
Go to previous/next method | ALT + UP/DOWN |
Show parameters for method | CTRL + P |
Quick documentation lookup | CTRL + Q |
General Shortcuts
Shortcut Description | Android Studio Shortcut |
---|---|
Delete line | CTRL + Y |
Safe Delete | Alt + DELETE |
Close Active Tab | CTRL + F4 |
Build and run | SHIFT + F10 |
Build | CTRL + F9 |
All purpose (Meta)Shortcut | CTRL + SHIFT + A |
Download this Essential Android Studio Shortcuts list as a printable PDF for quick reference.
Popular Articles
Comments on «Android Studio Shortcuts You Need the Most»
[…] earlier used IntelliJ IDEA, then you need some time get accustomed to it. I have compiled a list of Android Studio shortcuts you need the most and it will help you to ease into Android […]
[…] a couple of days to get used to Android Studio. To help you settle with it, I have listed essential Android Studio shortcuts in an earlier […]
Comments are closed for «Android Studio Shortcuts You Need the Most».
Источник
11 Android Studio Shortcuts every Android Developer must know
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 ):
This is the holy grail of the navigational shortcuts. It’s really simple. Search Android assets, navigate to the Gradle files, image resources, layouts, colors.xml and much more. There is nowhere you can’t go with the Double Shift shortcut.
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.
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.
So did you forgot what’s the shortcut for a replace action ? You forgot what’s the shortcut for a find action ? CTRL + SHIFT + A got you !! You can find actions such as Replace, Find, Run, Instant Run etc…
I searched for the Run action and it gave me all the run options Android Studio has to offer like running the garbage collector and debug runner.
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.
It can be time consuming to type out all the boilerplate code such as getters/setters in model classes, toString implementation, Parcelable Implementation and much more. Android Studio does all this for you. Press ALT+Insert on Windows or Command+N on Mac and android studio will list out all the options that are available such as override methods, implement interfaces, toString implementation etc…
Code Generation Android Studio Shortcut
When extending a Fragment or Activity class, you need to override certain methods such as onCreate and onCreateView. Apart from that you can also override lifecycle methods such as onPause, onResume, onDestroy. Android studio generates all this boilerplate code for you. Just press CTRL+O on Windows or Command+O on Mac and you’ll be presented with a list of methods that you can override.
You can see there are hundreds of methods which can be overridden and it is not possible to remember them all. So this shortcut comes in handy during development phase. You can also start typing a part of the name of method you want to override and the list will filter automagically.
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.
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.
Basic Completion Android Studio Shortcut
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.
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 :
Collapse/Expand Android Studio Shortcut
Again this is one of the most important shortcut that you can use. No need to manually indent all the nested if blocks or the for loops. Android Studio takes care of all the formatting. Just Press CTRL+ALT+L on Windows or Command+Option+L on Mac. The android studio will reformat all the code for you.
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.
So, this was my list of 11 most useful Android Studio Keyboard Shortcuts. These have helped me improve my productivity manifolds and hope it does for you as well.
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.
Источник