Tip 1299 Printable Monobook Previous Next
created August 9, 2006 · complexity basic · author kilgore trout · version n/a
To automatically update the ctags file when a file is written, I have added this to my vimrc:
function! UPDATE_TAGS() let _f_ = expand("%:p") let _cmd_ = '"ctags -a -f /dvr/tags --c++-kinds=+p --fields=+iaS --extra=+q " ' . '"' . _f_ . '"' let _resp = system(_cmd_) unlet _cmd_ unlet _f_ unlet _resp endfunction autocmd BufWrite *.cpp,*.h,*.c call UPDATE_TAGS()
Comments
To run a command in the background you may try script script#1582.
Since I wrote it, I prefer script#1343.
The big advantage, that I see, is that simply running ctags -a on a written file leaves behind in the tags file tags for items you've just deleted before writing the file. script#1343 removes all entries for the file you've just written and then runs ctags -a.