On pon sty 1 2007, Mikolaj Machowski wrote: > This won't work: you need a different variable name, see ":help E706".
Yeah, I forgot (not only about that). This is complete solution:: function! UpdateTags() call writefile(getline(1, '$'), '.tmp.cc', 'b') let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc') " Note: whitespaces around expand are tab chars. let alltags = system('grep -v " '.expand('%').' " tags') let tagstable = split(alltags, '\n') call add(tagstable, tags) call writefile(tagstable, 'tags', 'b') redraw! return ';' endfunction inoremap <expr> ; UpdateTags() Note: this is untested in real life, it doesn't return any errors. In good conditions execution of whole function takes 0.46s on big tags file (KMail source, tags size over 4MB, 10000 lines). Delay noticeable on my computer Sempron 2200, 512M RAM, old HD 5400rpm. In worse conditions it was taking up to 0.75s:: FUNCTION UpdateTags() Called 1 time Total time: 0.527128 Self time: 0.401542 count total (s) self (s) 1 0.000551 call writefile(getline(1, '$'), '.tmp.cc', 'b') 1 0.026373 0.000298 let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc') 1 0.000091 let stags = split(tags, '\n') 1 0.130731 0.031220 let alltags = system('grep -v " '.expand('%').' " tags') 1 0.128909 let tagstable = split(alltags, '\n') 1 0.000043 call extend(tagstable, stags) 1 0.240341 call writefile(tagstable, 'tags', 'b') 1 0.000033 return ';' FUNCTIONS SORTED ON TOTAL TIME count total (s) self (s) function 1 0.527128 0.401542 UpdateTags() FUNCTIONS SORTED ON SELF TIME count total (s) self (s) function 1 0.527128 0.401542 UpdateTags() Note however I've made one fatal mistake. ``ctags fname`` will point to tags in file .tmp.cc not our real current file! Filtering tags in Vim is possible and on small sample quite fast but still 0.5s is long. Maybe we should put that strain to the system:: function! UpdateTags() call writefile(getline(1, '$'), '.tmp.cc', 'b') call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2 tags') let tags = system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags') return ';' endfunction inoremap <expr> ; UpdateTags() And here we have the winner:: FUNCTION UpdateTags() Called 1 time Total time: 0.145700 Self time: 0.001068 count total (s) self (s) 1 0.000523 call writefile(getline(1, '$'), '.tmp.cc', 'b') 1 0.096118 0.000195 call system('grep -v " '.expand('%').' " tags > tags2 && mv -f tags2 tags') 1 0.049003 0.000294 call system('ctags --c++-kinds=+p --fields=+iaS --extra=+q -f - .tmp.cc | sed "s/\t\.tmp\.cc\t/\t'.expand('%').'\t/" >> tags') 1 0.000029 return ';' FUNCTIONS SORTED ON TOTAL TIME count total (s) self (s) function 1 0.145700 0.001068 UpdateTags() FUNCTIONS SORTED ON SELF TIME count total (s) self (s) function 1 0.145700 0.001068 UpdateTags() Below 0.15s (and even in worse conditions only up to 0.25s)! This is less then one keystroke of good touchtyper. This is for the price of portability but you can find grep/sed/mv for other systems so situation isn't hopeless. HTH m.