On 13/07/10 10:07, Aaron Guo wrote:
I have a file with some numbers like below:

-------------------------
12
31
4324
321
312
432432
213
321
-------------------------

And I want to plus every number 5 by using regular expression,
how to do it?


--
Aaron Guo

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

In addition to the substitute mentioned in other replies, you could try (untested)

        :setlocal nrformats=
        :%g/\d/normal 05^A

where ^A is obtained by hitting Ctrl-V (or Ctrl-Q if you use Ctrl-V to paste) followed by Ctrl-A. This would (I expect) add 5 (in decimal) to the first _number_ on every line containing at least one _digit_.

This doesn't "use a regular expression" other than the \d used to find applicable lines, but it is IMHO simpler: see :help CTRL-A


Best regards,
Tony.
--
A mathematician is a machine for converting coffee into theorems.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to