Thursday, March 31, 2011

Re: about submatch in VIM

Reply to message «about submatch in VIM»,
sent 21:10:08 01 April 2011, Friday
by Coiby:

`\=' must be the at the beginning of the replacement string, so you should use
`\="\/".(submatch(1)+1)' (`-1' is `decrease', not `increase'). By the way, you
could have used `\@<=':
$s!/\@<=[1-9]\+!\=submatch(0)+1!g

Original message:
> Hi, everyone!
> I want to increase the number in this format "/ddd" by one but also keep
> "/".
> But the following command doesn't work:
> $s/\/\([1-9]\+\)/\/\=submatch(1)-1)/g
> Can anyone give a tip?
> Thanks!
>
> --
> View this message in context:
> http://vim.1045645.n5.nabble.com/about-submatch-in-VIM-tp4273737p4273737.h
> tml Sent from the Vim - General mailing list archive at Nabble.com.

No comments: