Aar*_*hen 15 vim ansible vundle
我使用vundle作为vim的插件管理器.我想使用ansible自动化vundle插件安装.
但我无法自动做出规定:
- name: install vundle plugin
shell: vim +PluginInstall +qall
Run Code Online (Sandbox Code Playgroud)
以上是vim的ansible playbook YML文件.当ansible开始运行这个任务时,它会永远持续下去,它永远不会结束,它永远不会失败.直到我强迫它停下来CTRL C.
如果我直接在来宾操作系统中运行该命令,它运行正常,vim显示并完成安装.
这有什么问题?
==========================================
编辑:
在读完Roy Zuo答案后,打开vim的详细模式,我尝试了以下命令:
vim -E -s -c "source ~/.vimrc" +PluginInstall +qall -V
Run Code Online (Sandbox Code Playgroud)
以下是输出:
continuing in /home/vagrant/.vimrc
Searching for "/usr/share/vim/vimfiles/after/syntax/syncolor.vim"
Searching for "/home/vagrant/.vim/after/syntax/syncolor.vim"
Searching for "/home/vagrant/.vim/bundle/Vundle.vim/syntax/syncolor.vim"
Searching for "/after/syntax/syncolor.vim"
Searching for "colors/solarized.vim" in "/home/vagrant/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim74,/usr/share/vim/vimfiles/after,/home/vagrant/.vim/after,/home/vagrant/.vim/bundle/Vundle.vim,/after"
Searching for "/home/vagrant/.vim/colors/solarized.vim"
Searching for "/usr/share/vim/vimfiles/colors/solarized.vim"
Searching for "/usr/share/vim/vim74/colors/solarized.vim"
Searching for "/usr/share/vim/vimfiles/after/colors/solarized.vim"
Searching for "/home/vagrant/.vim/after/colors/solarized.vim"
Searching for "/home/vagrant/.vim/bundle/Vundle.vim/colors/solarized.vim"
Searching for "/after/colors/solarized.vim"
not found in 'runtimepath': "colors/solarized.vim"
line 188:
E185: Cannot find color scheme 'solarized'
finished sourcing /home/vagrant/.vimrc
continuing in command line
Run Code Online (Sandbox Code Playgroud)
当它无法找到.vimrc中指定的插件时,似乎vim停止了.知道怎么继续?
在这种情况下,您希望vim在EX模式下运行,这样可以避免显示需要tty进行显示的可视界面.请尝试以下命令.
vim -E -s -c "source ~/.vimrc" -c PluginInstall -c qa
Run Code Online (Sandbox Code Playgroud)
这里-E告诉vim以EX模式启动,并且"-s"(仅在EX模式下可用help -s-ex)意味着我们希望它在没有任何提示或信息性消息的情况下以静默方式运行.此外,在没有获取运行时文件的情况下,EX模式不知道如何执行PluginInstall命令.
-s Silent or batch mode. Only when Vim was started as "ex" or
when preceded with the "-e" argument. Otherwise see -s,
which does take an argument while this use of "-s" doesn't.
To be used when Vim is used to execute Ex commands from a file
instead of a terminal. Switches off most prompts and
informative messages. Also warnings and error messages.
The output of these commands is displayed (to stdout):
:print
:list
:number
:set to display option values.
Run Code Online (Sandbox Code Playgroud)
====================
至于您的Solarized配色方案缺失,因为您已经使用Vundle,因此很容易在您的产品中使用以下产品vimrc.
Plugin 'altercation/vim-colors-solarized'
Run Code Online (Sandbox Code Playgroud)
你应该确保colorscheme solarized线路跟在它后面.