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

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

Re: Doing numbered changes in a buffer


From: Quokka
Subject: Re: Doing numbered changes in a buffer
Date: Fri, 16 Dec 2005 09:10:15 +0800
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 Thunderbird/1.0.6 Mnenhy/0.7.2.0

gamename wrote:
Hi,

I have a tcl file with lots of messages which are about as descriptive
as this:

puts "something went wrong"
...
puts "something went wrong"

Is there any way to do a string replace in the buffer such that each
instance of "puts" would be assigned a unique message number? For
example:

puts "001 - something went wrong"
...
puts "002 - something went wrong"

You could use a keyboard macro and the keyboard macro counter

From the help:

The command `C-x C-k C-i' (`kmacro-insert-counter') inserts the
current value of the keyboard macro counter and increments the counter
by 1.  You can use a numeric prefix argument to specify a different
increment.  If you just specify a `C-u' prefix, the last inserted
counter value is repeated and the counter is not incremented.  For
example, if you enter the following sequence while defining a macro


So the sequence is
C-x (
search for puts "something went wrong"
move cursor back to start of string
C-x C-k -Ci -> inserts the current counter value
C-x )

The C-x e to repeat.

Hope that helps
Paul


reply via email to

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