可以使用vim-plug管理VIM插件,这是GitHub地址:junegunn/vim-plug: 🌺 Minimalist Vim Plugin Manager (github.com)
使用curl
命令安装vim脚本到当前用户目录下(~/.vim/autoload/plug.vim
)
-
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
修改 ~/.vim/vimrc
文件,在头部添加如下内容。在 call plug#begin()
和 call plug#end()
之间直接放入要添加的插件即可。
-
call plug#begin() " The default plugin directory will be as follows: " - Vim (Linux/macOS): '~/.vim/plugged' " - Vim (Windows): '~/vimfiles/plugged' " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged' " You can specify a custom plugin directory by passing it as the argument " - e.g. `call plug#begin('~/.vim/plugged')` " - Avoid using standard Vim directory names like 'plugin' " Make sure you use single quotes " Initialize plugin system " - Automatically executes `filetype plugin indent on` and `syntax enable`. call plug#end()
例如加入这几个插件
-
call plug#begin() " The default plugin directory will be as follows: " - Vim (Linux/macOS): '~/.vim/plugged' " - Vim (Windows): '~/vimfiles/plugged' " - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged' " You can specify a custom plugin directory by passing it as the argument " - e.g. `call plug#begin('~/.vim/plugged')` " - Avoid using standard Vim directory names like 'plugin' " Make sure you use single quotes #确保使用单引号!!! " On-demand loading Plug 'mhinz/vim-startify' " 修改vim欢迎页,能快速进入最近的编辑文件。 Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } " 侧边栏,能浏览目录结构。 Plug 'chr4/nginx.vim' " 增强对Nginx配置文件的语法支持 call plug#end()
最后,重新打开vim,并执行 :PlugInstall
命令来安装插件即可。具体方法如下。