vim代码片段插件ultisnips的使用

ultisnips是一个可以自动进行代码补全的插件,可以通过Vundle进行安装,要启用ultisnips,首先可以下面的配置信息写入到~/.vimrc

" Track the engine.
Plugin 'SirVer/ultisnips'

" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'

" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<c-b>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"

" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"

请注意我这边设置通过ctrl+b触发代码补全,因为我已经安装了YouCompleteMe插件,所以能使用tab来触发补全
配置完成后使用在vim中使用:PluginInstall安装插件
我们也可以自己定义语法,格式如下:

snippet 触发字符 ["代码片段说明" [参数]]
代码片段内容
endsnippet

猜你喜欢

转载自www.cnblogs.com/zmichael/p/12286036.html