146

Does anyone know how to highlight the current file in the project navigator, or a hotkey to expand folders to the active file?

I have looked around and couldn't find anything that points to this as an option.

Pang
  • 9,564
  • 146
  • 81
  • 122
Ryan
  • 1,735
  • 2
  • 10
  • 13

5 Answers5

185

Here is a nice feature: Autoscroll to Source and Autoscroll from Source.

It is available in all IntelliJ products .

Autoscroll to Source, Autoscroll from Source

Pang
  • 9,564
  • 146
  • 81
  • 122
funivan
  • 3,323
  • 1
  • 14
  • 19
  • This highlights the file, but it doesn't select it, so any more keyboard activity will still be registered in the editor window. – Alkanshel Feb 10 '17 at 18:20
  • In case u got here by googling and wonder if it still the same for your version: **this is the same for 2017** – Zanshin13 Aug 29 '17 at 09:08
  • 4
    2017 also has a crosshairs Icon up there when autoscroll is turned off. so you can click that and it will jump to source. – Artistan Dec 08 '17 at 17:06
  • autoscroll from source is what I needed. when I use the quick search (using shift+shift) it'll scroll to the file in the source. very useful thanks. – exts Jul 03 '18 at 22:07
  • @Artistan where is the crosshairs icon? – redfox05 Mar 28 '19 at 21:54
  • 1
    Found it! The crosshair icon is in between the 'Project' dropdown and the minimize/settings cog icon. It did not appear as the auto scroll options were still turned on. – redfox05 Mar 28 '19 at 21:55
183

On Demand

Should be used if you do not like when your Project View panel gets changed/moves without your consent.

Navigate | Select in... | Project View

Alt+F1, 1 for Windows/Linux

+F1, 1 (or fn+⌥ Opt+F1, 1) for Mac OS


You may also click on "target like" icon on actual Project View panel with your mouse:

enter image description here


If you wish to use shorter/single shortcut instead of standard 2-step shortcut:

  • install "Extra Actions" plugin
  • assign custom shortcut to newly provided "Select in Project" action

As of some 2017.x version (or maybe even 2016.x) the IDE has own dedicated Select in Project View action (so no need for additional plugin). You can find it in Keymap under the Other branch (hint: use search box to narrow the list).


Automatically

Can be used if you do not mind (or even want) to have Project View panel keep focused on currently edited file (so it scrolls/moves up and down/expands when needed).

NOTE: with frequently switching between the files (e.g. CSS & HTML) when you have a lot of files in your project such "scrolling" may become quite annoying pretty fast (especially if such files are located in the invisible-right-now part of the project tree).

Activate Autoscroll from Source option in Project View panel (right click on tool window header bar/title or use menu under "gear" icon):

enter image description here

In modern versions (2020.3 and newer) that option was renamed and is now called Always Select Opened File:

enter image description here

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • It seems that in newer versions, `Autoscroll from Source` has been renamed to `Always select opened file` and has been moved further down in the menu. – aggregate1166877 Jun 03 '20 at 04:13
  • Sorry but I dont see this shortcut working in Ubuntu (20) + PhpStorm (2022) – Jono Aug 05 '22 at 12:30
  • @Jono Your Linux / desktop manager may use the shortcut for own needs. 1) Check your OS / desktop settings; 2) Does the action work if you invoke the actual menu item via Main Menu? 3) What is the shortcut shown there? Maybe it's different in your Keymap. 4) If it's `Alt + F1` and it works when calling the menu item manually (with the mouse) -- go to `Settings | Keymap` -- there is a button next to the local search field. Use it and see if the IDE will recognize the shortcut. If it does not, then something intercepts it. – LazyOne Aug 05 '22 at 13:04
16

Just click the circular icon (with tooltip Scroll from Source) to navigate in the project directory tree and highlight the corresponding active file in the PhpStorm editor.

Screenshot - Scroll from Source

Pang
  • 9,564
  • 146
  • 81
  • 122
nikin
  • 331
  • 4
  • 8
14

On PhpStorm 2020.3 you have to click the cog icon in the project pane and select Always Select Opened Files:

screenshot

Dan
  • 3,329
  • 2
  • 21
  • 28
5

The above answers are all valid but unfortunately you'll have to enable them for each project.

There's a plugin from Jetbrains that will enable this behaviour by default for all new projects.

http://plugins.jetbrains.com/plugin/7575?pr=

Francis
  • 1,798
  • 1
  • 26
  • 32