首页 > 代码库 > vim 代码片段:通过vundle插件管理器安装ultisnips |centos6.5|vim7.2

vim 代码片段:通过vundle插件管理器安装ultisnips |centos6.5|vim7.2

背景:中午醒来,饭都没吃,突然想到要给vim增加个代码片段的功能,因为昨天使用了gedit的代码片段,感觉不错。为什么不直接使用gedit呢?因为我相信把时间投入到vim是不会错的,精通vim就好了。。。。就这样的一个想法,让我搞到了快5点。 T_T

1 安装vundle

地址在:https://github.com/gmarik/Vundle.vim,不过不需要在这边下载什么,看看文档就好

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim#没有git的话  yum install git#这样就安装好了,不骗你

 2 配置 .vimrc  在家目录下,没有就创建一个

    然后在.vimrc 的第一行加入如下代码,无脑拷贝就好了

set nocompatible              " be iMproved, requiredfiletype off                  " required" set the runtime path to include Vundle and initializeset 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, requiredPlugin ‘gmarik/Vundle.vim‘" The following are examples of different formats supported." Keep Plugin commands between vundle#begin/end." plugin on GitHub repoPlugin ‘tpope/vim-fugitive‘" plugin from http://vim-scripts.org/vim/scripts.htmlPlugin ‘L9‘" Git plugin not hosted on GitHubPlugin ‘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/‘}" Avoid a name conflict with L9Plugin ‘user/L9‘, {‘name‘: ‘newL9‘}" All of your Plugins must be added before the following linecall vundle#end()            " requiredfiletype 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

 要安装插件就在call vundle#begin()和call vundle#end()之间加入插件名称,比如要安装ultisnips,  

Plugin ‘SirVer/ultisnips‘  #这个是没有现成的代码片段的,自己怎么配置还没研究,但是可以用别人的,看下一行Plugin ‘honza/vim-snippets‘ #这个就应有就有了,都在 .vim/vundle/vim-snippets/snippets/下面#然后配置下面3行,没有的话是用不了代码片段功能的。这个是触发设置let g:UltiSnipsExpandTrigger="<tab>"let g:UltiSnipsJumpForwardTrigger="<c-b>"  #可以自行配置,比如我的<c-l>,作用是跳到下一个占位符let g:UltiSnipsJumpBackwardTrigger="<c-z>"  #我的<c-h>,上一个占位符

 这样真的就万事具备,只欠第3步,安装插件了

3 打开vim 执行 :PluginInstall (安装插件的意思), 等完成了会提示 done!

4 使用

先创建文件,比如 $ >test.html然后打开$ vim test.html然后输入form  按下tab键,。。。。。

 

vim 代码片段:通过vundle插件管理器安装ultisnips |centos6.5|vim7.2