ChatGPT解决这个技术问题 Extra ChatGPT

Locate current file in IntelliJ

How do I locate the current file in the project structure? (Similar to Visual Studio's Ctrl + Alt + L). What is the name of the operation (so I can define it in the keymap)


l
lrkwz

Alt + F1 (or Alt + Shift + 1 for linux) almost does what you want. You need to hit Enter afterwards as IDEA allows multiple "targets" for navigation (project structure, file structure etc).

(Note you can also set AutoScroll to Source and AutoScroll from source using the two "boxes with arrows" buttons above the project structure view but this can get annoying when it shoves you into the JDK source because you followed a reference to java.io.File.

The keymap defines it as Select current file or symbol in any view.


The current version of IntelliJ has renamed this to "Select In" under the Navigate category. The default shortcut is still ALT-F1
This shortcut is a system shortcut in Ubuntu. Following post describes how to remove this shortcut from Ubuntu: askubuntu.com/questions/126817/…
In the keymap it's called "Select in..." now.
it's faster if you just press "Alt + F1" and then "1" as the context menu appears.
Alt + Shift + 1 for me in 2017.3
w
worldsayshi

You can also click the little cross hairs button in the projects pane:

https://i.stack.imgur.com/0g4Cu.png

Note that the symbol won't be shown if Always Select Opened File (previously Autoscroll from Source) option is enabled.


I'm used to a right click on the editor pane > show in project, so this one-click approach was closer to what I was looking for than the other options here, thank you.
Is there a keyboard shortcut for that button?
Unfortunately, "Autoscroll from Source" only works when you switch to the source in the editor from some other file. If the source is the only editor tab you have open then you can't "switch to" it so Autoscroll won't occur: you have to open some other file so you can switch back from it. So it would be better if the cross-hairs icon was always available.
This question has been around for 8 years, received 50000+ Views and hundreds of up votes, surely JetBrains can see that that this is a commonly requested feature. I like @technophyle statement "is there a keyboard shortcut" and would love to see JetBrains actually make this available from key map
This alone has revolutionized how i use IDEA
A
Aswini V

Click the gear in the Project tool window and then Always Select Opened File (previously Autoscroll From Source)

https://i.stack.imgur.com/F3KcR.png


When this is enabled, Alt+1 can be used instead of Alt+F1, 1 to move focus to the sidebar from editor.
Amazing, can't understand why the default on this is OFF instead of ON. Thank you for this answer.
It's now called "Always Select Opened File". (Intellij 2020.1)
Because it's annoying that's why it's off
Somehow it works not right after "check" this) I recommend to reopen files to make this works. Intellij 2020.2
e
ericn

"Select in project View"

Little to no memorization required, reusable for every action in Intellij:

Use Find Action:

Press Shift + cmd + A (Pretty sure it's Shift + Ctrl + A for Windows and Linux) Type select in... Select Select in Project View in the suggestion list

https://i.stack.imgur.com/wUl5W.png


Nice! Select in Project View was the phrase I was looking for! Thanks!
M
M Patel

Do following will select your file automatically all time.

Right click on Project/Packages area > Autoscroll to Source. Right click on Project/Packages area > Autoscroll from Source.

Please find image below.

https://i.stack.imgur.com/0Apij.png


J
James Graham

I am using IntelliJ IDEA 2016.2 Ultimate.

Alt+F1, then press 1


C
Community

And make it autoscrollable from source without hitting shortcuts every time How to make Scroll From Source feature always enabled?


P
Pavel

There is no direct shortcut for such operation in IntelliJ IDEA 14 but you can install the plugin and set it the keyboard shortcut to the function that called "Scroll From Source" in keymap settings.

https://i.stack.imgur.com/CRBxQ.png


E
ErikE

In addition to the other options, in at least IntelliJ IDEA 2017 Ultimate, WebStorm 2020.2, and probably a ton of other versions, you can do it in a single shortcut.

Edit preferences, search for Select in Project View, and under Keymap, view the mapped shortcut or map one of your choice.

On the Mac, Ctrl + Option + L is not already used, and is the same shortcut as Visual Studio for Windows uses natively (Ctrl + Alt + L, so that could be a good choice.


"Select in Project View" work for me. In Ubuntu, I set it "Alt + L".
But it changes the view into "Project View", not useful when you want to see the file let's say in "Project Files"
@j4hangir I really don’t know what you mean.
In idea you can view the project in different views, all in the project pane, hence it's called Project View in the first place: there's Project, Projects, Project Files, etc, the shortcut opens the file in Project Pane -> Project View. Although, atm it's working properly again for me (having invalidated caches)
@j4hangir Got it. Thanks for explaining.
S
Sivani Patro

Open the project explorer ( default left side ) Click on the tiny wheel setting button Mark Auto scroll from source option.

Boom! You are done.


k
kingshuk

If you are using Mac(OSX)

Based on the current tab, to select the file on project is : FN + OPTION + F1

Then in the popup you can Select in: Project View > Select In: Project


What's Alt on a mac? 🤷‍♂️ Did you mean option? Control? Shift?
OPTION key in Mac generally corresponds to the ALT key in windows.
S
Smile

In Intellij Idea Community edition 2020.1 :

Right click on project header Select 'Always Select Opened File'

https://i.stack.imgur.com/6KZyn.png


D
Daniil Mashkin

in PyCharm 2021 this hotkey named Select File In Project View

https://i.stack.imgur.com/XDf8M.png