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

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

Related

I want to set shortcuts for "navigateBack" and "navigateForward" in Android studio on mac

workbench.action.navigateBack
workbench.action.navigateForward
My personal computer is a macbook.
I want to set the shortcut setting of the above command id in android studio, but I can't find it in key map.
It would be helpful if you could tell me the names of these commands, how to search them, or how to set them.
Go to Preferences -> Keymap, here you can use search or manually open Main menu / Navigate folder. Back and Forward elements show default key shortcuts, also you can double click on the element and set your own shortcut, modify existed ones etc.

Is there a way in Android Studio to use Ctrl+tab to navigate to recently used editor?

Is there a way in Android Studio to use Ctrl+tab to navigate to recently used editor?
Android Studio has two types of switching methods, as can be seen on the keymap settings:
"Recent Editors" - shows a list of recent editors but you need to leave the ctrl key and click up/down keys then another click to select the relevant editor.
"Switcher" - shows a quick list of recent editors. Setting Ctrl+tab to this will behave like many of the other editors in the market: Notepad++, Visual Studio, Eclipse ADT, etc...
You can use Ctrl+E to list last opened or edited files, use arrow key to move up and down.
Ctrl + tab is already doing that! it shows the switcher having the most recently used editor highlighted, after releasing Ctrl key it will switch to the editor, if you keep holding the Ctrl then there are 2 ways to navigate through the switcher, either by Tab, or by up and down arrows with Enter.
Another way is Navigate-> Back/Forward which will move cursor between edit locations in same file and move along to other files, the default key mapping for those are (Alt +Ctrl + Left)/(Alt +Ctrl +Right), which conflicts with windows mapping, Personally I am using Eclipse key mapping, so they are (Alt + left)/(Alt + right).
Don't forget that you can change any key mapping or add an extra key mapping from File->Settings->Keymap

Android Studio add watch shortcut

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"?

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'.

Visual Studio Hotkey - Go up one folder

In Windows Explorer, one can press Alt + Up Arrow to "Go up one folder"
When developing in Visual Studio, all too often I want to find a relative path from a file to some location higher in the hierarchy. Unfortunately, Alt + Up doesn't work in Visual Studio to travel up the folder hierarchy. Is there a different hotkey or a way to set one to do this inside the IDE?
I'm not sure if there is a built in shortcut, but you can create your own: Go to Tools | Options | Environment | Keyboard and look for the right command for going up to the parent directory. Then click the Press Shortcut Keys box and press your new shortcut.
Old post but I answer anyways.
One layer down (into folder): Enter
One layer up: Backspace
Select file: Arrow Keys
Select multiple files: Arrow Keys + Shift / Ctrl
Delete file: Delete
Unselect files: Esc

Resources