Article View: gnu.emacs.help
Article #189113Re: Operating on lines containing a pattern
From: Rich Alderson
Date: Fri, 03 May 1991 19:45
Date: Fri, 03 May 1991 19:45
29 lines
1932 bytes
1932 bytes
In article <BAUMGART.91May3100021@esquire.esquire.dpw.com>, baumgart@esquire (Steve Baumgarten) writes: >In "vi" (boo! hiss!), you can do something like this: > > :g/pattern/d > >to delete all the lines in a file that contain the pattern "pattern". M-x flush-lines will prompt your for a regexp that defines the lines you wish to delete. There is also M-x keep-lines. >Or this: > > :g/pattern/s/p1/p2/ > >to substitute p2 for p1 in all lines containing the pattern "pattern". >Is there some way to do this in Emacs, short of writing elisp code? >(Or if not, has someone already written appropriate elisp code?) Hmm. Well, that would take a little elisp, using re-search-forward or re-search-backward, and working like M-x replace-regexp or M-x query-replace-regexp on the selected line. There is also isearch-forward-regexp... -- Rich Alderson 'I wish life was not so short,' he thought. 'Languages take Tops-20 Mgr. such a time, and so do all the things one wants to know about.' AIR, Stanford --J. R. R. Tolkien, alderson@alderson.stanford.edu _The Lost Road_
Technical Details
Message-ID:
<1991May3.194541.12544@leland.Stanford.EDU>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!stanford.edu!leland.Stanford.EDU!newsReferences:
<BAUMGART.91May3100021@esquire.esquire.dpw.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,80ffebd709a40a03 X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-05-04 10:36:21 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!stanford.edu!leland.Stanford.EDU!news From: alderson@Alderson.Stanford.EDU (Rich Alderson) Newsgroups: gnu.emacs.help Subject: Re: Operating on lines containing a pattern Message-ID: <1991May3.194541.12544@leland.Stanford.EDU> Date: 3 May 91 19:45:41 GMT References: <BAUMGART.91May3100021@esquire.esquire.dpw.com> Sender: news@leland.Stanford.EDU (Mr News) Reply-To: alderson@Alderson.Stanford.EDU (Rich Alderson) Organization: Stanford University Academic Information Resources Lines: 29 In-Reply-To: baumgart@esquire.dpw.com (Steve Baumgarten)