How to see what function you are currently in?

In PhpStorm, when working in a large PHP function, is there an easy way to find out what function your cursor is in?

As it stands, I have to scroll upwards until I find the function signature, and then I press Left+Right on my keyboard to move my cursor so that it scrolls back down to where I was.

Suggestions/feature request: (1) Make it bold/highlight the method you're in in the Structure view, (2) Show the function name in the status bar. (2b) Make it pull up that Ctrl+F12 menu when you click the function name in the status bar.

1
12 comments

Well .. Structure tool window --> very last tool button (Autoscroll from Source) -- it will select the current function/method in Structure window. One minor thing -- it is not prominent enough for your liking (just a dotted rectangle -- not a bold text as you would like).

Also -- have a look at this ticket (Feature Request): http://youtrack.jetbrains.net/issue/WI-7583?projectKey=WI

2
Avatar
Permanently deleted user

Don't really want to have to click it every time to see where I am, but thanks. That feature request is about breadcrumbs... perahps I should submit a new one.

0
Avatar
Permanently deleted user

Hey Mark, heres what I do:

Gets me to the function I'm currently in: Alt + UP
Back to my original position before the move: Ctrl + Alt + LEFT
I find this is the quickest way to go about it.

Another way, as you have already mentioned, is to use Ctrl + F12 window, which also marks the current function.

5
Don't really want to have to click it every time to see where I am, but thanks.

What are you talking about? Where did I said it needs to be "clicked every time" ?? Please check the name of the button again -- especially the first word -- "Automatic".

That feature request is about breadcrumbs... perahps I should submit a new one.

And? It will show you in what class and function you are currently in -- isn't this you are after? (yeah -- a bit different presentation, but the same effect/result).

But in any case -- you are free to submit new Feature Request -- after comparing ideas your one may be better...

0

At one point I recall seeing the current function at the top of the window up around the area where the tabs are. I don't see it now in the 3.0 release version though and I'm not sure when it went away. It was useful. Otherwise I do the F12 suggestion now.

1
Avatar
Permanently deleted user

refactor your code - no function should be so long that you need a special feature to detect its scope.

0

Hi Eugene,

Agreed but there are a number of situations where that ideal breaks down. Because of that, this question is still valid.

Thanks!

0
Avatar
Permanently deleted user

Woops. May have been too tired. I was under the imression you had to click the button to have it highlight. I found the tool today...used it a bit. Was handy, but I still can't easily see what class I'm in :) My classes have so many methods that I can't even see the whole structure tree.

I submitted the feature request through YouTrack....no idea where it went though. Apparently I can't navigate that thing; it's not showing up under "by: me" anymore.

Edit: Got an email about it....link: http://youtrack.jetbrains.net/issue/WI-8862?projectKey=WI

0
Avatar
Permanently deleted user

I agree, but I didn't write all this code, and I don't exactly have time to go through hundreds of thousands of lines of code to correct it ;)

0

"At one point I recall seeing the current function at the top of the window up around the area where the tabs are"

I remember seeing that too. It was really rad. But it went away on next release. I've been looking for it ever since.

0

In PhpStorm 2019.1 EAP and recent releases I do see it in the breadcrumbs view. It will show the class and the method. I don't recall when it came back but it has been a while.

To make sure it's enabled though go to the preferences:

Editor -> General -> Breadcrumbs

Click "Show Breadcrumbs"

Choose all the languages you'd like to display.

3

Per Mark's original request, the structure view does highlight the current method you're in. And yes it is quite helpful.

1

Please sign in to leave a comment.