Vundle是一款流行vim插件管理工具,也是代表了现在和以后vim插件管理的方式的革新。本文我们来讲解安装vundle和用vundle来安装Vim的emmet插件。
首先安装 Vundle
vim ~/.vimrc
把下列代码加到 .vimrc
文件后面:
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
Plugin 'VundleVim/Vundle.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
安装emmet-vim
在
Plugin 'VundleVim/Vundle.vim'
后面加入
Plugin 'mattn/emmet-vim'
然后打开一个vim.执行
:PluginInstall
Vundle.vim和emmet-vim就会安装好,emmet-vim默认的快捷键是 ctrl+y+,
,但是由于你按下ctrl+y后得非常快地按下逗号才会生成代码,并且大多数时候你是来不及按下逗号ctrl+y就失效了,所以我们需要定义自己的触发键,在~/.vimrc文件夹后加入这句代码
let g:user_emmet_expandabbr_key = '<C-E>'
这样emmet的触发键就变为Ctrl+e了,一开始我把触发键改为 <Tab>
, 经过测试后发现改为Tab键后就只能用Tab键来进行触发Emmet,而无法用Tab键来进行代码缩进了,所以放弃了Tab键改为了Ctrl+e, 我们可以试验一下,
vim index.html
输入!然后按下Ctrl+e,就会生成
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
</html>
表示通过Vundle成功安装Vim的emmet插件了,我们可以用Vundle来管理我们的Vim插件,更多的用法请参考本博客关于Vbundle的文章。