From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?S2FpIEdyb8Ofam9oYW5u?= Newsgroups: gmane.emacs.help Subject: Re: Regexp: match any character including newline Date: Wed, 16 Oct 2013 17:31:57 +0200 Message-ID: <525EB16D.90804@gmx.net> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1381937495 31193 80.91.229.3 (16 Oct 2013 15:31:35 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 16 Oct 2013 15:31:35 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 16 17:31:36 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VWT4S-0006Qz-J1 for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Oct 2013 17:31:36 +0200 Original-Received: from localhost ([::1]:47941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWT4S-0004ab-6Q for geh-help-gnu-emacs@m.gmane.org; Wed, 16 Oct 2013 11:31:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWT48-0004UR-HV for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 11:31:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWT41-0002Im-5d for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 11:31:16 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:54209) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWT40-0002IY-Qp for help-gnu-emacs@gnu.org; Wed, 16 Oct 2013 11:31:09 -0400 Original-Received: from marcie.lan ([188.100.165.77]) by mail.gmx.com (mrgmx102) with ESMTPSA (Nemesis) id 0MYtId-1VJ0np13EB-00VhWl for ; Wed, 16 Oct 2013 17:31:06 +0200 User-Agent: Postbox 3.0.8 (Macintosh/20130427) Original-Newsgroups: gmane.emacs.help In-Reply-To: X-Provags-ID: V03:K0:DaWBSO9g1qOECcLBJCKqwDPoT8H9RzpNioiMERtkHqD4Uvd0v3E 3J6es7QR28a9nlg9bf4XCqJnioju1Ei6IW5nUWXH3MU7Yzd40PerCYhNTGteJ2Vdwo/DbXP 5HruINRcFkfRgnd2WQoHc4XPESWi9MCGd3mu4B2zvboqiLrUG75bG7JJbKyNS9d9zT+d3CI w7B98oM8zdmATuK6SQcww== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.20 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94039 Archived-At: Yuri Khan wrote: > > To this end, I want to do a regexp replace of: > > === > \(.*?\)\(.*?\) > \(.*?\) > === > > with > > === > \1 > \2 > \3 > === You can use keyboard macros, but you will need a mode that understands XML. Let's say you install nxml (it's part of Emacs I think). Let's say the content is in a file foo.xml, so that nxml mode is turned on. Consider that point is before the . Now you can use C-M-f to move it before the . Now you can use C-M-n to move it after the closing . Even if the content of ... contains tags! So you can record a keyboard macro that does the following steps: - Move after the - Insert "" - Move to after the with C-M-n - Insert "" (using C-c /, say) - Insert a newline - Insert "" - Move to after the with C-M-n - C-c / to insert "" - "", C-M-n, C-c / - Use C-M-f to move past the closing After all of this, you've got: foo bar baz Now you can do this: You set the mark with C-space. You move backward over the whole thing with C-M-p. Now the whole ... is marked. Now you can use query-replace to replace , , and with nothing in the highlighted region. (Need to experiment a bit whether the region goes away after a query-replace. If it does, C-x C-x might be your friend.) See? No regex anywhere. Way cool! Instead, you're exploiting the navigation that you get from Emacs modes. Kai