From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: Select/highlight and *copy* matches of some regex Date: Mon, 27 Jun 2022 18:12:30 +0200 Message-ID: References: <82a978f3-e974-4d8f-b87e-5707ffec0b5b@www.fastmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="2bUDK5DsZd9lrBK5" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26516"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 27 18:29:12 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o5rbs-0006h0-GF for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Jun 2022 18:29:12 +0200 Original-Received: from localhost ([::1]:57282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o5rbq-0004Jc-TE for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 27 Jun 2022 12:29:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5rLt-0004zJ-Mo for help-gnu-emacs@gnu.org; Mon, 27 Jun 2022 12:12:47 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:47452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o5rLm-0001WK-PW for help-gnu-emacs@gnu.org; Mon, 27 Jun 2022 12:12:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Cywn9Fbo3FLfhWghTiy3LzDnW0PStnCE2wRvhTN3XOc=; b=JLLA8DTFzDoGVDjYzD1MdiV2uw rUWtPqtWCawXs7ar2Z6YmcXPKf8tEiX87robcKvFtWYBeN8pnJgq+tG0M18uzE6WKQwF5YAuybHX3 0fJzuFl7wU4+L0do5Psaj7hkbIIjOn6dwWSGCIwdG4y6xH2ZJ2Ub0+rhQER4Qg6up5/JyNztlJx2F gukOGh8NT0B7D7GvniWLUUZ3IynGbdXDJy1YwvhQZaMArBa2zM12uc5ou34ZltR1lucFQOclaBCup obWBgBjVMPWXshFzQJ+hjkSfaQHOX5z9pvvG3bo4zJPTE/VKbrZ9XnNk4ohdAzw5AliESPYY0ZLmZ tWAWmMkQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1o5rLi-0004tT-TG for help-gnu-emacs@gnu.org; Mon, 27 Jun 2022 18:12:30 +0200 Content-Disposition: inline In-Reply-To: <82a978f3-e974-4d8f-b87e-5707ffec0b5b@www.fastmail.com> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138128 Archived-At: --2bUDK5DsZd9lrBK5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 27, 2022 at 05:52:48PM +0200, Joost wrote: > Hi all, >=20 > I've been looking for at least an hour for something that my Sublime-usin= g 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 match= es so that you can yank them in a new buffer. >=20 > The first part, highlighting all matches, is not a problem. But I haven't= found a way yet to then extract all matches. >=20 > 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 a= s a rectangle, so that you can use `yank-rectangle`, but I haven't been abl= e to make that work. >=20 > 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 --=20 t --2bUDK5DsZd9lrBK5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCYrnW6AAKCRAFyCz1etHa Rq0BAJ9BR/P2//vWqtBSPJTmdGd/Q2QTrACfVFwFpiGe5sWWu4q5MyQhzMALKgM= =P51W -----END PGP SIGNATURE----- --2bUDK5DsZd9lrBK5--