vim 插件管理器 Vundle 简易教程

Life is short, you need vim

前言:

  • 在代码编辑的过程中, 我们常常要使用 "", (), [], {} 等符号来包围一个变量或表达式, 或者是删除文本周围的包围符号.
  • 这样的操作即使是使用 vim 提供的 { command + text objext/motions } 操作来实现, 仍然会十分繁琐. 于是我们会需要借助 vim-surround 这样的插件, 来简化操作以提高效率, 做一个lazy coder. 在这个需求下, 使用vim插件管理器来快捷地管理对应插件就变得十分有必要.
  • 本文将会讨论vim插件管理器 vundle 的安装和使用.

vundle

  • vundle 是一个 vim 的插件管理工具. 可以用于从本地和远程的git仓库 安装/更新vim的插件.
  • 参考: VundleVim/Vundle.vim​github.com

安装 vundle

  • 使用 git 克隆到本地
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

使用 vundle 安装vim插件

  • 流程简述
    要使用 vundle 安装vim插件, 首先需要在 vundle 的配置文件中定义/输入所需的插件, 然后使用 vim 命令来完成安装.

  • 配置vundle插件
    将以下内容复制为 ~/.vimrc 文件, 然后根据自己的需求来替换定义插件的示范文本.

set nocompatible " be iMproved, required
filetype off " required



" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vimcall 
vundle#begin()
" alternatively, pass a path where Vundle should install plugins
" call vundle#begin('~/some/path/here')


" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'


"--------------------------------------- 定义插件的示例 ---------------------------------------

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.


" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'


" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'


" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'


" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'


" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.


Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}


" All of your Plugins must be added before the following line
"--------------------------------------- 定义插件结束 ---------------------------------------

call vundle#end() " required


filetype plugin indent on " required
  • 添加 vim 插件到配置中 ( 以 vim-surround 为例) :
    将这一行复制到 .vimrc 的插件定义部分
 Plugin 'tpope/vim-surround'

  • 执行安装:
    进入 vim
    键入以下命令
:PluginInstall
// 或
:PluginUpdate

结语

至此, 我们就成功地通过 Vundle 添加了一个 vim 插件, 如果要使用其他的 vim 插件管理器 (例如 vim-plug) 来管理 vim 创建, 同样需要进行上文中的类型配置, 具体的操作请参考相应的 github repo.

你可能感兴趣的:(vim 插件管理器 Vundle 简易教程)