Right now I have the following in my .vimrc
:
au BufWritePost *.c,*.cpp,*.h !ctags -R
There are a few problems with this:
When you combine these two issues I end up pushing the additional enter too soon (before ctags -R
has finished), then see the annoying error message, and have to push enter again.
I know it doesn't sound like a big deal, but with the amount of file writes I do on a given day it tends to get really annoying. There's gotta be a better way to do it!
au BufWritePost *.c,*.cpp,*.h silent! !ctags -R &
The downside is that you won't have a useful tags file until it completes. As long as you're on a *nix system it should be ok to do multiple writes before the previous ctags has completed, but you should test that. On a Windows system it won't put it in the background and it'll complain that the file is locked until the first ctags finishes (which shouldn't cause problems in vim, but you'll end up with a slightly outdated tags file).
Note, you could use the --append
option as tonylo suggests, but then you'll have to disable tagbsearch
which could mean that tag searches take a lot longer, depending on the size of your tag file.