从命令行执行 vim 中的命令

从命令行执行 vim 中的命令

我想:helptags ~/.vim/doc在 vim 中运行,但是从命令行运行。

目的是偶尔与其他命令一起运行该命令以使我的工具保持最新状态(可能是在我的开发机器上的 cron 作业中)。

我环顾四周man vim,但无法弄清楚我需要通过什么选项。

我认为这是 vim 的一个常见问题,但我使用 Mac 和 Ubuntu 进行开发。

答案1

vim(1)手册页中:

   +{command}

   -c {command}
               {command}  will  be  executed after the first file has been
               read.  {command} is interpreted as an Ex command.   If  the
               {command}  contains  spaces  it  must be enclosed in double
               quotes (this depends on the shell that is used).   Example:
               Vim "+set si" main.c
               Note: You can use up to 10 "+" or "-c" commands.

     ...

   --cmd {command}
               Like using "-c", but the command is  executed  just  before
               processing  any  vimrc file.  You can use up to 10 of these
               commands, independently from "-c" commands.

:q!如果您想退出,只需将其作为最后命令即可。

相关内容