> Hi,
>
> I have a file which has lines like this.
>
> area : 37.24;
> power : 1.28, 2.73, 3.84;
>
> I need to substitute each number with it's double (number*2).
> Is there anyway I can do this in VIM?
> I don't have perldo command in my version of VIM.
>
%s/[0-9.]\+/\=2.0*str2float(submatch(0))/g
-from-
[0-9.]\+ one or more digits or periods
-to-
\= ... evaluate following expression
2.0 ... obvious
* ... also obvious
str2float(submatch(0)) take entire match and convert that string to a float
/g ... as many matches as possible per line
HTH,
Chip Campbell
--
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
No comments:
Post a Comment