Here’s a useful reminder from Wilfred Hughes:
M-x imenu: lists all the functions, classes and top-level variables in a file. Great for getting an overview, or for jumping around.
Works in pretty much every language too! pic.twitter.com/kibmFD2y8N
— Ⓔ Command of the Day (@ecotd) January 1, 2018
I say “useful reminder” because—at least for me—it’s easy to forget about it. That’s true even though I have it bound to an easy keystroke, Ctrl+..
I originally set it up to make package configurations in my
init.el easy to find but it’s actually handy for navigating in most languages. It gives you a list of functions and top level variables and, if you do such things, classes. When combined with
counsel-imenu you get a nice Ivy-like list of candidates that you can successfully refine to narrow in on exactly what you’re looking for.
The reason that I often forget to use it is that
swiper is so powerful that it’s my automatic go-to-tool when I’m looking for something in a file. That’s true even if I just want to glance at it and not necessarily move to it. Still,
imenu is useful and gives a nice overview of what’s going on in a source file. It’s worth trying to remember to use it.