454

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)

Jasper
  • 2,166
  • 4
  • 30
  • 50
ripper234
  • 222,824
  • 274
  • 634
  • 905

14 Answers14

640

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.

lrkwz
  • 6,105
  • 3
  • 36
  • 59
butterchicken
  • 13,583
  • 2
  • 33
  • 43
  • 50
    The current version of IntelliJ has renamed this to "Select In" under the Navigate category. The default shortcut is still ALT-F1 – smith324 May 30 '13 at 04:40
  • 15
    This shortcut is a system shortcut in Ubuntu. Following post describes how to remove this shortcut from Ubuntu: http://askubuntu.com/questions/126817/how-to-disable-alt-f1-alt-f2-shortcuts – Halil Aug 14 '14 at 08:56
  • 4
    In the keymap it's called "Select in..." now. – seanmcl Oct 13 '14 at 15:02
  • 4
    it's faster if you just press "Alt + F1" and then "1" as the context menu appears. – Steve Waters Apr 06 '16 at 10:35
  • 2
    `Alt + Shift + 1` for me in 2017.3 – isalgueiro Apr 09 '18 at 10:10
  • If only Mac computers use F1, F2 ... too and all Windows PC vendors don't require me to press an extra key `Fn` sigh – ericn Jun 19 '18 at 02:44
  • 1
    FWIW In Ubuntu 20.04 LTS, Alt-F1 shows all windows, so remapping was needed for "Navigate -> Select In..." – Richard Logwood Aug 07 '20 at 02:15
  • 1
    Can also setup your own keybinding in Preferences -> KeyMap -> Other -> Select in Project View -> Assign your keystroke/shortcut (Shift + cmd + A) – kisna Oct 24 '22 at 20:20
483

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

enter image description here

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

worldsayshi
  • 1,788
  • 15
  • 31
Timo Reimann
  • 9,359
  • 2
  • 28
  • 25
  • 1
    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. – Shastings Jul 31 '15 at 19:55
  • 39
    Is there a keyboard shortcut for that button? – technophyle Sep 02 '15 at 18:06
  • 3
    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. – Adrian Pronk Jan 19 '17 at 03:25
  • 6
    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 – David Cruwys Aug 24 '17 at 03:39
  • 1
    This alone has revolutionized how i use IDEA – Karaja Oct 17 '18 at 20:10
  • It is funny how I wouldn't be able to tell by just the look of the icon.. but now that I was told what it was for... the symbol makes sense for its propose. – LameLoura Jun 29 '21 at 08:24
  • Thanks!!!!! I've been trying to figure out how to make that button appear – Austin Poole Jan 26 '22 at 14:06
158

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

cogwheel menu

Aswini V
  • 3
  • 4
Rami Kuret
  • 3,581
  • 2
  • 15
  • 17
36

"Select in project View"

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

Use Find Action:

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

enter image description here

ericn
  • 12,476
  • 16
  • 84
  • 127
  • 3
    Nice! `Select in Project View` was the phrase I was looking for! Thanks! – Joaquin Iurchuk Aug 10 '20 at 04:03
  • Another way is to setup keybinding in Preferences -> KeyMap -> Other -> Select in Project View -> Assign your keystroke/shortcut (Shift + cmd + A) – kisna Oct 24 '22 at 20:18
23

Do following will select your file automatically all time.

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

Please find image below.

enter image description here

M Patel
  • 424
  • 5
  • 13
19

I am using IntelliJ IDEA 2016.2 Ultimate.

Alt+F1, then press 1

Vy Do
  • 46,709
  • 59
  • 215
  • 313
17

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

Community
  • 1
  • 1
Yauhen
  • 2,435
  • 1
  • 17
  • 18
12

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.

enter image description here

Pavel
  • 4,912
  • 7
  • 49
  • 69
12

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.

ErikE
  • 48,881
  • 23
  • 151
  • 196
  • 1
    "Select in Project View" work for me. In Ubuntu, I set it "Alt + L". – Emdadul Sawon Sep 06 '18 at 11:52
  • But it changes the view into "Project View", not useful when you want to see the file let's say in "Project Files" – j4hangir Feb 03 '21 at 00:42
  • @j4hangir I really don’t know what you mean. – ErikE Feb 04 '21 at 01:04
  • 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 Feb 04 '21 at 01:57
  • 1
    @j4hangir Got it. Thanks for explaining. – ErikE Feb 04 '21 at 18:09
7
  1. Open the project explorer ( default left side )
  2. Click on the tiny wheel setting button
  3. Mark Auto scroll from source option.

Boom! You are done.

Sivani Patro
  • 109
  • 1
  • 2
5

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

kingshuk
  • 472
  • 1
  • 4
  • 10
Asip Asipo
  • 59
  • 1
  • 2
4

in PyCharm 2021 this hotkey named Select File In Project View

enter image description here

Danil
  • 4,781
  • 1
  • 35
  • 50
3

In Intellij Idea Community edition 2020.1 :

  1. Right click on project header
  2. Select 'Always Select Opened File'

enter image description here

Smile
  • 3,832
  • 3
  • 25
  • 39
0

In 2023 there is still no default shortcut for locating the current file in the Project view. However it is easy to set up a custom shortcut for it.

Open Settings, go to Keymap and search for "Select file in project view". It should be in the "Other" section and should have a crosshair icon. Right click on it and select "Add keyboard shortcut". I set it up to CTRL + SHIFT + L, but of course any unmapped key combination will work.

Enjoy! For me this is a very often used feature and having a shortcut for it is a significant productivity boost.

enter image description here

András Szepesházi
  • 6,483
  • 5
  • 45
  • 59