In order to define the range by 2 icon's click with the same icon's
menu, I have added a called func MarkAndSumLastCol
" Fonctions mathématiques utiles {{{1
fu! <sid>Sum() range
"
let beginMessage = "total:"
"
let lines=getline(a:firstline, a:lastline)
call filter(lines, 'v:val =~ "\\d$"')
call filter(lines, 'v:val !~ beginMessage')
" 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-len(beginMessage))
" garde seulement le chiffrage de chaque ligne (derniere colonne)
let lines=map(lines, 'split(v:val)[-1]')
"
call append(a:lastline, printf("%s%s%02f", beginMessage, separator,
eval(join(lines,'+'))))
unlet lines
"
delmarks a
endfu
fu! <sid>MarkAndSum()
" if mark a does not exist put it
try
silent marks a
catch /^Vim\%((\a\+)\)\=:E283/
mark a
return
endtry
" calculate sum
exec "'a,.SumLastCol"
endfu
com! -nargs=0 -range SumLastCol :<line1>,<line2>call <sid>Sum()
com! -nargs=0 MarkAndSumLastCol :call <sid>MarkAndSum() " called by an
icon
--
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.