When you execute an external command with
:!, Vim doesn't know what the external command might have written to the terminal, so it waits for you to confirm that you are ready to continue.
To avoid that, you can use the
system() function like this:
autocmd BufWritePost *.cpp call system("ctags -R")
autocmd BufWritePost *.h call system("ctags -R")
You could also simplify that to one command:
autocmd BufWritePost *.cpp,*.h call system("ctags -R")
A problem with calling
system() is that you lose any error messages it might produce. That can be solved by using
echo instead of
call, like this:
autocmd BufWritePost *.cpp,*.h echo system("ctags -R")
However, that echoes an empty line to the display when the command succeeds, causing another "Press ENTER or type command to continue" prompt. The simplest solution for that is to increase the height of the command line:
Another, more complicated solution would be to echo a message only if there is one. Then you avoid the prompt without losing any screen space.
autocmd BufWritePost *.cpp,*.h let msg=system('ctags -R') | if msg!="" | echo msg | endif