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

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

Re: Emacs regexp/incrementer question


From: Christopher J. White
Subject: Re: Emacs regexp/incrementer question
Date: Fri, 17 Jan 2003 08:44:48 -0500
User-agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.2 (powerpc-apple-darwin)

>>>>> "tim" == Tim Morley \(remove vegetable for email address\) <Tim> writes:

tim> Does anybody know of a way to include an incrementing number in a
tim> regexp search-and-replace in Emacs? What I want to do is search
tim> for a regexp, and the first time I find it, replace it with "case
tim> 1", the second time replace it with "case 2", etc.

Here's a function that I wrote a while ago...almost what you want.
When run interactively, gives something like:

  Replace [n] skip [1] case1 [2] case2 [3] case3?

Press [n] to skip to next match, [1-3] to replace with the
case1-3, [return] to quit.

Could be modified pretty easily to autoincrement
a value in the replace string.

...cj

Attachment: replace.el
Description: query-replace-regexp-select

-- 
------------------------------------------------------------------------------
 Christopher J. White                                    address@hidden
------------------------------------------------------------------------------ 

reply via email to

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