Ubuntu 16.10 上 Vim-plug 的安装

Ubuntu 16.10 上 Vim-plug 的安装

我是 Ubuntu 的新用户,我需要一些有关插件的帮助。根据这个网站,我vim-plug使用curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim命令安装。我还按照建议创建了目录~/.vim/plugged。到目前为止,我知道我必须在里面(在~/.vimrc文件中)安装我的插件:

call plug#begin('~/.vim/plugged')

call plug#end()

这表明我必须使“下载 plug.vim”的内容在“autoload”目录中可用。

问题 1:这里的“自动加载”目录是什么?

事实上,我想安装vim-plug几个插件,比如nerdtree。我理解的程序是访问网站https://github.com/scrooloose/nerdtree,仅需scrooloose/nerdtree安装插件的部分:

call plug#begin('~/.vim/plugged')

Plug 'scrooloose/nerdtree'

call plug#end()

然后执行:PlugInstall

问题2:有人能告诉我哪里有问题吗(如果有的话)?

答案1

:h autoload

AUTOMATICALLY LOADING FUNCTIONS 
                                                        autoload-functions
When using many or large functions, it's possible to automatically define them
only when they are used.  There are two methods: with an autocommand and with
the "autoload" directory in 'runtimepath'.

...

Using an autoload script 
                                                        autoload E746
This is introduced in the user manual, section 41.15.

Using a script in the "autoload" directory is simpler, but requires using
exactly the right file name.  A function that can be autoloaded has a name
like this: 

        :call filename#funcname()

When such a function is called, and it is not defined yet, Vim will search the
"autoload" directories in 'runtimepath' for a script file called
"filename.vim".  For example "~/.vim/autoload/filename.vim".  That file should
then define the function like this: 

        function filename#funcname()
           echo "Done!"
        endfunction

The file name and the name used before the # in the function must match
exactly, and the defined function must have the name exactly as it will be
called.

因此,这autoload是一个目录,您可以在其中放置定义函数的文件,并且只有在第一次调用该函数时才会读取该文件。这使得启动速度更快。

相关内容