On Mon, Jun 27, 2022 at 05:52:48PM +0200, Joost wrote: > Hi all, > > I've been looking for at least an hour for something that my Sublime-using colleagues seem to be able to do out of the box... Highlight all matches of some regex in the current buffer and then copy/kill *all* of those matches so that you can yank them in a new buffer. > > The first part, highlighting all matches, is not a problem. But I haven't found a way yet to then extract all matches. > > I've also looked for third-party packages, but haven't been able to find anything. I read a few times that `multiple-cursors` can kill all matches as a rectangle, so that you can use `yank-rectangle`, but I haven't been able to make that work. > > So what am I overlooking here? I mean, there *must* be a way, right? Not a direct answer to your question, but perhaps similar. If you can live with selecting /lines/ containing a match, there's "occur" (M-x occur). Each match is a "live link" to the location. You can even edit the matches in the occur buffer itself (key 'e'). I didnt try what happens when you do a query-replace in the occur buffer while it is in "edit" mode. But worth a try ;-) Cheers -- t