From: Katsumi Yamaoka <yamaoka@jpl.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Add +2 to all numbers in file
Date: Fri, 27 Feb 2009 17:32:22 +0900 [thread overview]
Message-ID: <b4mocwol1pl.fsf@jpl.org> (raw)
In-Reply-To: 278c44c4-39e2-4a43-a4f7-f047bb433653@33g2000yqm.googlegroups.com
>>>>> sharky wrote:
> 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!
Try `M-x all+2 RET':
(defun all+2 ()
(interactive "*")
(save-excursion
(goto-char (point-min))
(while (re-search-forward "[0-9]+" nil t)
(replace-match (number-to-string
(+ 2 (string-to-number (match-string 0))))))))
next prev parent reply other threads:[~2009-02-27 8:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-27 8:18 Add +2 to all numbers in file sharky
2009-02-27 8:32 ` Katsumi Yamaoka [this message]
2009-02-27 9:11 ` sharky
2009-02-27 17:58 ` Pascal J. Bourguignon
2009-02-27 21:55 ` David Kastrup
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b4mocwol1pl.fsf@jpl.org \
--to=yamaoka@jpl.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.