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

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

RE: How to replace string for a block?


From: Drew Adams
Subject: RE: How to replace string for a block?
Date: Wed, 27 May 2009 06:35:05 -0700

> >> > Is there a way to perform 'M-x replace-string' only for a block?
> >>
> >> Emacs documentation is your friend. Try to read the 
> >> documentation by doing C-h f replace-string
> >> It is possible to do what you want, at least in Emacs 23 
> >> pretest version.
> >
> > It's possible in any Emacs version. Just narrow the buffer 
> > to the block first:
> > `C-x n n'. Widen it again after replacing: `C-x n w'.
> 
> There's no need to narrow the buffer: just set the mark and the point
> and M-x replace-{string,regexp} won't go beyond, as documented.  Well,
> you've activated transient-mark-mode, of course.  Who would disable it?

That only works with transient-mark-mode on (as you mention) and with the region
active, and it works then only for Emacs 21 and later.

Summary:

* Narrowing to the region works in all Emacs versions, with or without
transient-mark-mode on.

* If transient-mark-mode is on and the region is active, then you need not
narrow the buffer (in Emacs 21 or later).






reply via email to

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