Hi sinbad!

On Fr, 26 Mär 2010, sinbad wrote:

> abc 123 dafdf
> 132 adfadf bg
> dffdd 55 dafd
> dfdsf 98
> 
> i want the sum of all the numbers in the above text, assuming there
> will be only one occurence
> of a number in a line how this can be done. ?

fu! <sid>Sum() range
   let lines=getline(a:firstline, a:lastline)
   let lines=map(lines, 'matchstr(v:val, ''\d\+'')')
   echo eval(join(lines, '+'))
endfu

com! -range Sum :<line1>,<line2>call <sid>Sum()

regards,
Christian

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