Charles Choi has an excellent post on imenu. I’ve used it for a long time via the excellent councel-imenu
but I’ve never really understood its scope or essential raison d’ĂȘtre. I’ve always thought of it as a way of locating functions and variables in a programming language buffer but that turns out to be a very circumscribed view of its purpose.
Choi has a much better explanation. He explains that what it really does is index many types of files that have some sort of definitions. This includes programming language files, of course, but also text files such as Org, Markdown, and other structured files.
You can get a feeling for how it works by trying it out on various types of files. It’s builtin so there’s no need to load it or do anything special to try it out. If you’re a swiper user, I recommend binding some easy binding to councel-imenu
. I have it bound to Ctrl+. so it’s easy to invoke. Councel-imenu will bring up a completing read list of targets in the minibuffer that makes it easy to select the target.
Take a look at Choi’s post for other ways of using imenu. If you’re a menu user, you can easily add it to the menu. If, like me, you avoid the mouse, imenu is completely accessible through the keyboard. Choi recommends having it enabled by default but I find that having it an easy key shortcut away works well for me.