Ok Christian, it works very well.

I obtain this result by marking a and then moving my cursor to enlarge
the range I want to sum up from mark 'a.
But meanwhile, calling directly :'a,.SumLastCol<CR> by clicking a menu
icon, I would like that first click put mark a then second click do
the call as it is done  actually.
Can you show me how you will do that ?


"mark a
foo                             2.1
bar                             0.9
total..........3.000000


foobar                          2.0
total.............5.000000


_______________________________
fu! <sid>Sum() range

        "
        let lines=getline(a:firstline, a:lastline)
        call filter(lines, 'v:val =~ "\\d$"')

        " trouve la longueur de la derniere ligne afin d ecrire le total
        " a bonne colonne
        let maxLen=0
        for item in lines
                let currentLen=len(lines[len(lines)-1])
                if currentLen > maxLen
                        let maxLen=currentLen
                endif
        endfor

        let separator = repeat('.', maxLen)

        " garde seulement le chiffrage de chaque ligne (derniere colonne)
        let lines=map(lines, 'split(v:val)[-1]')
        "
        call append(a:lastline, printf("total%s%02f", separator,
eval(join(lines,'+'))))
        unlet lines

endfu

_______________________________
com! -nargs=0 -range SumLastCol :<line1>,<line2>call <sid>Sum()
_______________________________
amenu icon=$HOME/vimfiles/icons/somme.bmp
ToolBar.Total :so $HOME/vimfiles/plugin/
utils.vim<CR>:'a,.SumLastCol<CR>
_______________________________

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