leandromartinez98 wrote:
> Just for the sake of records, the very nice commands suggested here
> don't
> work well if the numbers have leading zeroes. For example, using
>
> :'<,'>s/\%V\d\+/\=submatch(0)+5
>
> in a table like:
>
> 0101
> 0102
> 0103
> 0104
>
> provides
>
> 70
> 71
> 72
> 73
> 74
You can tweak your regexp to strip the leading zeros:
:\<,\>s/\%V\(0*\)\d\+/\=submatch(2)+5
However, it will eat the leading zeros, not replacing them after
the substitution. If you know the width, you can hack it even
further with
\=matchstr(repeat('0', 4) . (submatch(2)+5), '.\{4}$')
where "4" is the number of characters to pad to, and "5" is the
increment you want.
-tim
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---