2024-01-14-232214 Searching through open buffers in Emacs

[2024-01-14 23:22]

EmacsStuff ProductivityJournal CodeJournal

Several times, especially while working with a lot of files, whether in a code base of a bunch of interconnected ZettelkastenNotes, one forgets which file contains that particular snippet of text, particularly among those files that are already open. consult-line-multi is a handy solution to find that buffer, which is suggested to be bound to M-s L. This can be combined with Embark to obtain an occur like buffer which can be edited.

The above defaults to doing so among the project buffers if projectile is active. It can be made to search all open buffers using the prefix C-u. It also provides a preview if that is enabled. A project root is usually identified by a .git or a .projectile

There are other commands, like multi-occur-in-matching-buffers which can search buffers matching a regexp. That can be useful if one knows the format before hand, like org files. helm-swoop and variants would probably be the equal commands if you are using the helm package.