Search code examples
vimctags

Run bash command whenever ViM is being started


So I would like to run the following command whenever ViM starts:

ctags -R .

Is this possible? Preferably I would like to have something in my ~/.vimrc that does this.

Thanks!


Solution

  • You can use :help :!cmd in your .vimrc:

    !ctags -R .
    

    To avoid the hit-enter prompt (but still see the ctags output), prepend :silent:

    silent !ctags -R .
    

    To completely silence the output (but then you won't notice problems until you implement another notification), use system() instead:

    call system('ctags -R .')
    

    To avoid that the run time of ctags delays using Vim, you can start the task asynchronously (on Unix):

    call system('ctags -R . &')