Android Studio add watch shortcut - android-studio

Is there any shortcut for Add Watch in android studio?
While debug windows is focused I can use Alt + Insert, but this is not working in code editor.

There is no direct shortcut for Add to Watches but you can define your own.
Go to File -> Settings -> Keymap
Expand 'Other' folder at last and find 'Add to Watches'.
Double Click / Right Click on it and select 'Add Keyboard Shortcut'.
Enter your keys and Done!

Did you try to assign a combination to your liking under preferences -> keymap -> search for "watches"?

Related

Disable shortcut in Android Studio

I always accidentally do the following keyboard combination SHIFT + ALT + X which will close all of my open files in Android Studio.
UPDATED
My apology, I should have been more clearer asking question. The first thing I did is to google it and I did saw the post in stackoverflow but I can't find SHIFT + ALT + X
See screen shot here:
Go to File -> Settings -> Keymap search for Clear Context and remove or replace the shortcut
Move to File -> Settings -> Keymap and change Keymaps settings to your keymap,for Example : Visual Studio,so that you can use the short cut keys like in Visual Studio.
From here,you can enable or disable any shortcut, you want.
Type in Search, Clear Context.
Then on it Right Click, and you will get your choice.

Android Studio | Navigate to file in the project explorer from the editor

I find myself with many files open in the editor (in separated tabs), and sometimes I want to find specific file in the project explorer.
Does there is any shortcut to reveal the file in the project window ?
EDIT to do the question more clear I add a picture:
There isn't a single key combo that can do this, as far as I know, but you can go with
On Windows
Alt + F1 followed by either 1 or enter
On Linux (using Gnome)
Alt + Shift + 1 followed by either 1 or enter
On Mac OS
Option + F1 followed by either 1 or enter
Android Studio is based on intelliJ, which has a function to open the current file or symbol in various views. The default key combo (in Windows) is ALT + F1.
This offers to open the current file or symbol in a bunch of different views, but the first option (with shortcut key 1) is the project view.
It's the same as choosing the Navigate > Select in... menu option, followed by option 1.
Note that you can customise the key mappings, or select other defaults instead of the default intelliJ configuration, so this might not be the case with your set up.
You can check the key mapping in settings > Key map and search for Select In... or, more simply, click the navigate menu and look at the Select In... option to see the shortcut key displayed in the drop down.
You can go to Navigate -> Select In, which has default shortcut Option+F1 on macOS.
For Xcode, the shortcut is Cmd+Shift+J. If you want the same, follow these steps
Go to Android Studio -> Preferences -> Keymap
Search for Select In in Navigate
Right click and select Add Keyboard Shortcut
Press Cmd+Shift+J

Shortcut to close a opened tab in android studio

What is the shortcut to close the opened tab in android studio?
I'm new to the android studio. I tried with CTRL+W. It's not working. I searched for a while. But I haven't get it. Any one please provide me the shortcut to close the opened tab.
You can try pressing CTRL+F4 in order to close opened tabs in Android Studio
As mentioned above, type CTRL + ALT + S to get into settings and in the keymap dialog search for Close, but the thing you want to reassign is
Close Active Editor
For Mac it is not set by default. Here is how I did it.
Android Studio 4.1 > Preferences > Keymap search for Close Active Editor right click > Add Keyboard Shortcut. Then assign anything you want. Alt+W is a good one.
If you right click on a tab header, the context menu shows you the current key binding next to the word Close (by default Ctrl+F4).
Follow the steps mentioned in other comments (type CTRL + ALT + S to get into settings and in the keymap dialog search for Close) and what you actually need to change is [editor tabs] / [close]
(android studio 3.6.1)
On a Mac, it's command + F4.
If you're like me, you may have to do command + fn + F4

shortcut in Android Studio to locate the current editing src file

Do you know how to check the location of current editing file in the project tree panel (the very left panel of the Android Studio), except manually. (The worst case is that all the folders there are collapsed)
The Navigate->Class shortcut can show me the src file in edit panel (central panel) quickly. Then I want to know the src file's logic location in project tree (left panel), so that I can add some new files in the same package quickly. (e.g. right-click the package and add new Class).
Currently, I have to expand the project tree and find it folder by folder.
Actually, in Xcode there is such a shortcut named "Reveal in Project Navigate"
What a convenient way it is.
I wonder whether this is also supported in Android studio.
Thanks
You can use the Scroll from Source button in the Project Toolbar in the left of Android Studio.
Another solution is Alt+F1+1. You can also read Locate current file in IntelliJ for more answers.
Just enable the following option!
In Android Studio 4 it is now Always Select Opened File under the Settings menu in the project view.
For automatic scrolling, you can do following:
You need to ensure Autoscroll to Source and Autoscroll from source is enabled.
Whenever you change the file the Project tree will be highlighted according.
I have observed some slowness and lag if project size is big(several modules or huge code base) and you use short cut Ctrl + N to navigate to a class.
So the alternative would be to either to click following icon:
OR
Use keyboard shortcut:
Alt + F1 + 1 or Alt + F1 + Enter
You can add shortcut (keymap) to "reveal current editing file in project explorer" command.
Press Ctrl + Alt + S, for Windows user, to open Settings
Select Keymap on the sidebar
Find the command using search box, type this into it: select in project view
Right click the result then select Add Keyboard Shortcut
Type any keyboard combination you want, for example, me prefer shortcut Ctrl + K to reveal current editing file on project explorer
Click OK button. It will prompt you to remove keyboard shortcut you typed from existing command, so just click Remove button.
I'm new to android development. I used to code in Sublime Text 3. One of first thing I do to make android development feels more enjoyable is binding all shortcut I used in Sublime Text 3 to Android Studio. Now, it feels like home :)
For Mac users: Option+fn+F1, then Enter.
Android Studio 3.6.3 (April 2020)
Go to Preferences > Keymap & search for "Select in Project View" and assign your keyboard shortcut.
Under options menu, select Auto scroll from Source
Navigate -> Select In.. -> Project View -> Project
open pref -> Keymap, then search 'select file in project view', not 'select opened file'.

How to format code in Android Studio (IntelliJ IDEA)

I want to format code in a freshly created Android application.
I messed up the code in this manner:
private static final
int AUTO_HIDE_DELAY_MILLIS
= 3000;
I want to format it with Ctrl + Alt + L, but it is not repairing the code. I use Windows 8.1.
Just right-click on the project or directory, and select Reformat Code
If you want to:
Order/FormatCode: Ctrl + Alt + L
Implement Methods: Ctrl + I
Override Methods: Ctrl + O
There isn't any need for them to be capital letters. This is just for the example.
First you will need to configure how your code is formatted. This can be done by going to
[Main Menu] -> File -> Settings
then go to
(Project Settings) -> Code Style -> Java
In this area you can define all the formatting rules that you would like to apply to your code.
Now you should check (or change) the keyboard shortcut for reformatting code by going to
[Main Menu] -> File -> Settings
then go to
(IDE Settings) -> Keymap
Just type Reformat Code into the search box at the top right to find it.
Once this is done, highlight the code you want to reformat and use the keyboard shortcut to reformat your code based on the rules you defined.
In Android Studio (on the Mac), I select the code chunk, and then select the Code menu item and click Auto-Indent Lines.
See screenshot:
Shortcut key (on Mac) is Ctrl + Alt + I.
At least on my Android Studio version, "keep when formatting - line breaks" was enabled by default. So you need to go to
Preferences → Editor → Code Style → Java and disable that checkbox (see the below screenshot).
Alt + Ctrl + Shift + L is the shortcut key for arranging the code in Ubuntu (Android Studio).

Resources