epanda wrote:
foo                0.5
foobar           1
bar                0.5


Is it possible to sum which result as 2 by using regexp and writing
the result line below all lines checked ?

Well, you can sum them in pure vim with either of the following (depending on whether your vim was built with +float so you'd have to check your :ver output) one-liners (if they line-break, rejoin them)

:let tot=0|g/\d\+\%(\.\d\+\)\=/let tot+=str2float(matchstr(getline('.'), '\d\+\%(\.\d\+\)\='))

or if it wasn't built with +float you can still sum integers:

let tot=0|g/\d\+\=/let tot+=matchstr(getline('.'), '\d\+')


You can then use "tot" for whatever you want (inserting into the file, just echoing it, using it as a count later on, whatever)

-tim


--
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

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to