Sublime Text: show current outer element name
Asked Answered
C

1

8

Having a long routines, one gets sometimes lost and it would be handy to know which class/function the cursor is currently in (without the need to scroll all the way up, looking for the first outer block declaration). Any ideas how to get this in Sublime Text 3?

I'm mostly interested in a solution for Python, but I suppose there should be some general way (plugin?) to have this. I can imagine having the name written in the status bar, for example.

Coexecutor answered 17/6, 2014 at 18:9 Comment(2)
Did you ever find a way?Draconic
any update? vscode has sticky classes - looks epicHydrogenous
E
5

If you press accel-r, or type @ inside the Quick-open files by name command palette(accel-p), you can see the current method/routine name highlighted. All this is in the default key binding of course.

Edit: after looking around, I found Function Name Display which does exactly what you want. It shows the current function name in the status bar.

Eddy answered 17/6, 2014 at 18:32 Comment(4)
Yes, but I only see a function (not the class), and it's also a bit inconvenient to press accel-r just to see this information. If it's justified to show the info about line and column number in the status bar all the time, then I believe the class name is not less appropriate.Coexecutor
I found a package that does what you want. It only shows the function name though, not class name and function name.Eddy
Thanks for the tip, but unfortunately it is quite naive and limited. It does not track the end of a function (or class), and is easily confused by nested classes (which makes it unusable for Django models with Meta class defined).Coexecutor
The repository linked hasn't been updated in a while, and currently one of the features (class name display) isn't working. This fork fixes it beautifully, so I suggest linking the post to it. Hope it gets merged back to the original repo (I have no affiliation to neither).Chaparral

© 2022 - 2024 — McMap. All rights reserved.