[prog] replacement strings

john.sturdy at ul.ie john.sturdy at ul.ie
Mon May 24 08:55:59 UTC 2010

Sam Watkins writes:
 > On Mon, May 24, 2010 at 01:39:41PM +1000, Miriam English wrote:
 > > I just re-read the relevant part of geany's  manual and found that it can do
 > > tagged replacements, though with a  slightly different syntax than I normally
 > > use.
 > >
 > > Thanks again Sam. You've opened my eyes to other things.
 > Another thing you can do with good editors...

The regexp replacement facilities in Emacs got even more wonderful in
Emacs 22, with a couple of new \ thingies on the replacement side:

\# gives the number of replacements done so far (so you can number lists, etc)

\( begins an Emacs-Lisp expression, the result of which is inserted,
so for example to force things that look like UK-style postcode elements to
upper-case you could replace



\(upcase \&)

where \< \> mean start and end of word, and \& means the whole matched

You can combine \# and \( too, if you want to number things but not
counting from 0, or not counting in ones, or converting to letters,
e.g. to count from 42 upward you can use \(+ \# 42)

for more examples.  (I'm glad I'm not the only person who gets excited
about new editor facilities!)


More information about the Programming mailing list