Android Studio and few of its Shortcuts

Developer must know all the shortcuts of the IDE they are using and must have the environment friendly to their will. Given a keyboard he must be able to navigate through the IDE (android studio) all around. This can increase his productivity manifolds and is also less distracting than shifting to a mouse/touchpad during typing.

Setting the Theme

For Windows: File > Settings > Appearance & Behavior >Appearance > Theme and then choose the desired Theme. To change the color of the editor text, you can go to File > Settings > Editor and change the desired property.

For Mac: Android Studio > Preferences > Appearance & Behavior > Appearance > Theme and then choose the desired option. For the color of the text, go to Android Studio > Preferences > Editor and then change the desired property according to you.

Changing Color of Logcat

For Windows: File > Settings > Editor >Color Scheme > Android Logcat and change the default color by unchecking the “Inherit values from” option.

For Mac: Android Studio > Preferences > Editor > Color Scheme > Android Logcat and change the default color by unchecking the “Inherit values from” option.

Profiler

For Windows: ctrl + shift + up arrow

For Mac: cmd + shift + up arrow

Finding Actions

For Windows: ctrl + shift + a
For Mac: cmd + shift + a

Rename file/variable

Android Studio Shortcuts : Android Studio provides a better way of doing this. All you need to do is select a file and then right-click on it and then click on Refractor > Rename or simply shift + f6 and then enter the new name Refract the changes.

Split Screen

Split Screen is a new feature that is provided by almost every modern day’s IDE. By using Split Screen, you can use two screens at a time i.e. the same window will be split into two parts, either vertically or horizontally. In order to split the window, right-click on the tab of the file that you want to split and then choose Split Vertically/Horizontally.

Distraction Free Mode

To enable the Distraction Free Mode, go to View > Enter Distraction Free Mode (in Windows) or View > Appearance > Enter Distraction Free Mode (in Mac).

Adding Macros

To make a macro, go to Edit > Macros > Start Macro Recording and then the macro recording will be started. Now, do the desired operations by pressing the keys. Stop the Macro recording by pressing the Macro recording button and then give the name and key combination to your macro.

Code Completion

if you want to write the code for a Toast, then just write “T” and press ctrl + j (or cmd + j), you will be given a list of possible items. Select Toast and click Enter.

Find information about methods and parameters

You can find the information related to a method by putting the cursor on the required method and then pressing the ctrl + q (in Windows) or ctrl + j (in Mac).

Extended Selection

In a method block, there can be one or more if block, for block, while block, etc. So, to select some lines together we can use the approach of extended selection. Press ctrl + w (in Windows) or option + up arrow (in Mac) and the desired lines will be selected. To select more lines, keep on pressing ctrl + w.

Move Statements up/ down

Inside a function, you can select one or move lines of code and collectively move all the selected statements to up or down by pressing ctrl + shift + up arrow (to move up) and ctrl + shift + down arrow (to move down) in Windows. For Mac, you can use option + shift + up/down

Find all occurrences

Sometimes we use a variable many times in our code and at a certain time we may need to change the variable name. To find all the occurrences of something, press ctrl + f (in Windows) and cmd + f (in Mac) and enter the name of the variable.

Line Number and Method Separator

You can put line numbers to your code and method separator also. This will make your code more readable. All you need to do is click on File > Settings > Editor > General > Appearance > Select Line Number/Select Method Separators.

For Mac, you can find this in Android Studio > Preferences > Editor.

Multi cursor Feature

You can edit to more than one lines at a particular instant of time. For doing so, go to a particular word and click alt + j (in Windows) or ctrl + g (in Mac). This will select the next appearance of that word in the file. Now you have to write only once.

Last Copy & Paste

You can choose from your last 5 Copy/Paste operations by clicking ctrl + shift + v (in Windows) or cmd + shift + v (in Mac).

Open Class

In order to open a class in Android Studio, press ctrl + n (in Windows) or cmd + o (in Mac) and then type the class name.

Open File

To open file press ctrl + shift + n (in Windows) or cmd + shift + o (in Mac).

Find Declaration / Jump to Definition

You can find the declaration of any class and its method by clicking on that class and pressing ctrl + b (in windows and Linux) or cmd + b (in Mac).

Move between tabs

You can move between tabs by pressing alt + left/right arrow (in Windows) or cmd + shift + (left) and cmd + shift + (in Mac).

Last tab

You can switch between last tabs by using ctrl + tab (in Windows) or cmd + tab (in Mac).

Format your code

You can format your code by using ctrl + alt + l (in windows) or cmd + option + l (in Mac). Formatting means rearranging the declaration of attributes. This makes the code more readable.

Auto-indent line

You can apply indentation by using ctrl + alt + i (in Windows) or control + option + i (in Mac).

Find

You can find something in a file by using ctrl + f (in Windows) or cmd + f (in Mac).

Find and Replace

You can use find and replace feature by pressing ctrl + r (in Windows ) or cmd + r (in Mac).

Hardcoded String to resources

You can move your hardcoded string to string.xml file or any other resources file by just clicking on the string and pressing alt + enter (in Windows) or option + return (in Mac) and then Extract String Resource.

Build and Run

To build and run your app, press shift + f10 (in Windows) or control + r (in Mac).

Last edited location

You can directly move on to the last edited location in a particular file by pressing ctrl + shift + backspace (in Windows) or cmd + shift + delete (in Mac).

Close active editor tab

You can close the active editor tab by pressing ctrl + f4 (in Windows) or cmd + w (in Mac).

Prevent Android Studio Logcat from clearing the log for the current application when it crashes.

To do that you need to go to the Android Monitor panel and choose Edit filter configuration on the right side dropdown.

Apply a proper code style to your IDE (IntelliJ / Android Studio).

Go to Preferences → Code Style → Java and in a Scheme dropdown, you can choose your code style (or set up a new one).

Use split screen for increasing efficiency.

User need to right mouse click on the tab of your main screen and choose the Split Vertically / Horizontally feature.

Use Live Templates

  • you can use a shortcut: cmd + j (Windows / Linux: ctrl + j).
  • you can use many already defined templates, like for Toasts or if conditions.
  • you can use your own custom templates.

Helpful commands

Helpful command is Search for command:

cmd + shift + a (Windows / Linux: ctrl + shift + a).

Let’s say you want to close the current tab and you don’t know-how. You just type: close and you’ll get a proper shortcut/command.

Choose from the last copy / pastes (manage your clipboard)

cmd + shift + v (Windows / Linux: ctrl + shift + v).

Enable multicursor feature: control + g (alt + j for Windows / Linux).

Open a class: cmd + o (Windows / Linux: ctrl + n).

Open any file: cmd + shift + o (Windows / Linux: ctrl + shift + n).

Open symbol: cmd + option + o (Windows / Linux: alt + shift + n).

Go to implementation: cmd + option + b (Windows / Linux ctrl + alt + b).

Go to declaration: cmd + b (Windows / Linux: ctrl + b).

Go to type declaration: control + shift + b (Windows / Linux: ctrl + shift + b).

Go to super: cmd + u (Windows / Linux: ctrl + u).

Move between tabs: cmd + shift + [ (move left) or cmd + shift + ] (move right) (Windows / Linux: alt + ← / →).

Move between Design / Text tabs in layout’s view: control + shift + ← / → (Windows / Linux: alt + shift + ← / →).

Close a current tab: cmd + w (Windows / Linux: ctrl + F4).

Hide all windows: cmd + shift + F12 (Windows / Linux: ctrl + shift + F12).

Minimize Android Studio instance: cmd + m (Windows / Linux: ctrl + m).

Format your code: cmd + option + l (Windows / Linux: ctrl + alt + l).

Auto-indent lines: control + option + i (Windows / Linux: ctrl + alt + i).

Implement methods: control + i (Windows / Linux: ctrl + i).

Smart code completion: control + shift + space (Windows / Linux: ctrl + shift + space).

Find: cmd + f (Windows / Linux: ctrl + f).

Find and replace: cmd + r (Windows / Linux: ctrl + r).

Move hardcoded strings to resources: option + return (Windows / Linux: alt + enter). The shortcut must be used when a caret is on a text.

Build and run: control + r (Windows / Linux: shift + F10).

There are regular updates on android studio on timely basis , few shortcut keys either removed or few more shortcut keys may be added .

Happy APP Coding 🙂


Discover more from mycodetips

Subscribe to get the latest posts sent to your email.

Discover more from mycodetips

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top