Emacs Occur

I love Emacs. It’s a great text editor and platform for doing all sorts of things. One of the ways that it makes a great editing environment is that things are extensible, often live in the environment. One of the things I used to use is a package called “ioccur“, this allowed you to edit occurrences of a specified text across the document. This mirrored a built-in function called “Occur“, which showed you each line or instance of the occurrence across the document. The biggest problem was that once you found stuff, you had to swap back and forth between the list and the actual document. I have since learned about the ability to edit the document right from the “Occur” results.

Once you have a list of items, you can press e to enter edit mode. Each line becomes linked to their buffer line and you can make edits to whatever you want and they’ll be reflected, live. Once you’re done, you can return to the “Occur” mode (which allows you to do more) by pressing C-c C-c (a common Emacs ‘complete’ command).

Here is the feature in action:

Here is the effect in action, inside my .profile file.

By Nathan DeGruchy

IT Support extraordinaire. FOSS lover and proud Husband and Father.