[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Add +2 to all numbers in file
From: |
David Kastrup |
Subject: |
Re: Add +2 to all numbers in file |
Date: |
Fri, 27 Feb 2009 22:55:39 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
pjb@informatimago.com (Pascal J. Bourguignon) writes:
> sharky <landhaj@yahoo.com> writes:
>
>> Hi!
>>
>> I have a file with a lot of numbers. It looks like this:
>>
>> xx, xx, xx--xx, xx, xx, x
>> xx, x, xx--xx, xx--xx, x
>> xx, xx
>> xx, xx, xx--xx, xx--xx, xx--xx
>>
>> You get the picture. Can I make emacs add 2 to each and everyone of
>> these numbers?
>>
>> Please help!
>
> If you have only one file, you can edit it interactively. With recent
> emacs (eg. 22, perhaps even 21), you can substitute an expression.
>
> Type:
>
> M-x replace-regexp RET \([0-9][0-9]*\) RET \,(+ 2 (car (read-from-string
> \1))) RET
A bit complicated.
C-M-% [0-9]+ RET \,(+ 2 \#&) RET
--
David Kastrup