help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vim equivalent in emacs %5,50s/serah_term/replace_term/gc


From: Rupert Swarbrick
Subject: Re: vim equivalent in emacs %5,50s/serah_term/replace_term/gc
Date: Fri, 09 Nov 2007 10:18:59 GMT
User-agent: Pan/0.132 (Waxed in Black)

> 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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]