运行 bash 命令每当 ViM 开始时

Run bash command whenever ViM is being started

所以我想 运行 每当 ViM 启动时执行以下命令:

ctags -R .

这可能吗? 最好我希望在我的 ~/.vimrc 中有一些东西可以做到这一点。

谢谢!

通过将此添加到 .vimrc 来解决它:

" === generate ctags
call system('ctags -R . ')

你可以在你的 .vimrc 中使用 :help :!cmd:

!ctags -R .

为了避免 hit-enter 提示(但仍能看到 ctags 输出),在前面添加 :silent:

silent !ctags -R .

要完全静音输出(但在执行另一个通知之前您不会注意到问题),请改用 system()

call system('ctags -R .')

为避免使用 Vim 时 ctags 的 运行 时间延迟,您可以异步启动任务(在 Unix 上):

call system('ctags -R . &')