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

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

Re: Emacs: adding 1 to every number made of 2 digits inside a marked reg


From: Gregory Heytings
Subject: Re: Emacs: adding 1 to every number made of 2 digits inside a marked region.
Date: Thu, 23 Sep 2021 09:26:07 +0000



Imagine I've got the following in a text file opened under Emacs:

some    34
word    30
another 38
thing   59
to      39
say     10
here    47

and I want to turn into this, adding 1 to every number made of 2 digits:

some    35
word    31
another 39
thing   60
to      40
say     11
here    48


This is a typical job for a macro. Move the cursor to the beginning of the first item of the list, then do:

C-x (
C-e
M-b
M-: (insert (format "%d" (1+ (number-at-point))))
C-k
C-a
C-n
C-x )

Then type C-x e e e ...



reply via email to

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