我可以让 vim 安装包并在后台关闭吗?

Ree*_*ese 5 vim docker

我一直在玩 Dockerfiles,在设置开发环境时,有一个手动步骤我还没有解决。要在我的 vimrc 中安装这些包,我必须打开 vim,然后它会下载所有包并说按 Enter 继续。我想在 Dockerfile 中将这一步作为 RUN 命令执行。我试过使用vim -c 'q',它会:q在 vim 打开时运行命令,但是自动捆绑安装脚本仍然需要按 Enter,而且无论如何它都不起作用,因为 vim 抱怨输入和输出不是到终端。

我想用 Dockerfiles 而不是图像来做到这一点

这是我的 .vimrc 中似乎相关的部分

    " Setting up Vundle - the vim plugin bundler
        let iCanHazVundle=1
        let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
        if !filereadable(vundle_readme)
            echo "Installing Vundle.."
            echo ""
            silent !mkdir -p ~/.vim/bundle
            silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
            let iCanHazVundle=0
        endif
        set rtp+=~/.vim/bundle/vundle/
        call vundle#rc()
        call GetBundles()
        if iCanHazVundle == 0
            echo "Installing Bundles, please ignore key map error messages"
            echo ""
            silent :BundleInstall
        endif
    " Setting up Vundle - the vim plugin bundler end
Run Code Online (Sandbox Code Playgroud)

Mic*_*ior 3

我发现通过将我的插件列在单独的文件vundle.vim. 这可以避免在Ex 模式.vimrc下无法正常运行的插件和设置。

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()

" Add plugins
Plugin 'bling/vim-airline'
" ...
Run Code Online (Sandbox Code Playgroud)

然后您可以在 ex 模式下运行安装,如下所示。

vim -E -u NONE -S ~/.vim/vundle.vim +PluginInstall +qall > /dev/null
Run Code Online (Sandbox Code Playgroud)