From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rupert Swarbrick Newsgroups: gmane.emacs.help Subject: Re: vim equivalent in emacs %5,50s/serah_term/replace_term/gc Date: Fri, 09 Nov 2007 10:18:59 GMT Organization: ntl Cablemodem News Service Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1194628494 1857 80.91.229.12 (9 Nov 2007 17:14:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2007 17:14:54 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 18:14:58 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IqXRZ-0001LW-9M for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2007 18:14:57 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IqXRN-0007BP-Nr for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Nov 2007 12:14:45 -0500 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!exabot.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!62.253.162.218.MISMATCH!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!news.highwinds-media.com!newspeer1-win.ntli.net!newsfe5-win.ntli.net.POSTED!53ab2750!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Pan/0.132 (Waxed in Black) Original-Lines: 23 Original-NNTP-Posting-Host: 86.20.30.52 Original-X-Complaints-To: http://netreport.virginmedia.com Original-X-Trace: newsfe5-win.ntli.net 1194603539 86.20.30.52 (Fri, 09 Nov 2007 10:18:59 GMT) Original-NNTP-Posting-Date: Fri, 09 Nov 2007 10:18:59 GMT Original-Xref: shelby.stanford.edu gnu.emacs.help:153632 X-Mailman-Approved-At: Fri, 09 Nov 2007 12:11:21 -0500 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49105 Archived-At: > Hi I recently moved from vim to emacs and need help to search and > replace using line numbers(say between two lines 5 and 50). This can be > done in vim as %5,50s/serah_term/replace_term/gc > What is equivalent in emacs? > Thanks, > Iluvindo I don't know whether you can explicitly restrict the replace-string function, but the simplest way to do what you want is with narrow-to- region. Go to the start of line 5 and C-space to set the mark and then go to line 50 and C-x n n to call narrow-to-region. Emacs will warn you you're doing something weird, so tell it that you really want to. Then most of the buffer disappears, leaving just the stuff you want to change. Now replace-string just changes stuff in this region. To get back to the whole file, you need C-x n w which calls "widen". For getting to lines, M-g g is goto-line, which might help. Rupert