epanda wrote:
Hi,

I have some lines like that


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 ?


foo                0.5
foobar           1
bar                0.5

total             2

You could do it all with Vim script, but in my opinion, the best way to do something like that is to use a tool such as awk, in conjunction with Vim's filter mechanism. E.g., Visually select the original 3 lines, then execute...
'<,'>!awk '{sum += $2; print} END {printf "total\t\%f", sum}'

Brett Stahlman


Thanks


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