这对我也不起作用!
但是通过 doc 挖掘Ultisnips
,我找到了一个替代方案:h UltiSnips#SnippetsInCurrentScope
. GetAllSnippets()
此帮助部分中有一个示例函数,它返回list
可用于当前缓冲区的片段,如下所示:
function! GetAllSnippets()
call UltiSnips#SnippetsInCurrentScope(1)
let list = []
for [key, info] in items(g:current_ulti_dict_info)
let parts = split(info.location, ':')
call add(list, {
\"key": key,
\"path": parts[0],
\"linenr": parts[1],
\"description": info.description,
\})
endfor
return list
endfunction
在片段列表可用后,我不确定您的要求是什么。如果你想跳转到代码片段的定义,你可以使用下面文档中函数的修改版本来实现。这将填充并打开快速修复列表:
function! GetAllSnippets()
call UltiSnips#SnippetsInCurrentScope(1)
let list = []
for [key, info] in items(g:current_ulti_dict_info)
let parts = split(info.location, ':')
call add(list, {
\"text": key,
\"filename": parts[0],
\"lnum": parts[1],
\"context": info.description,
\})
endfor
call setqflist([], ' ', { 'title': 'Snippets', 'items' : list})
" Open Quickfix list as soon as it is populated
copen
endfunction
或者,如果您使用fzf-vim,您可以使用该:Snippets
命令列出、模糊查找和调用代码段。
编辑:
我现在看起来很傻!:D 解决方案就在h g:UltiSnipsListSnippets
:
请注意,某些终端仿真器不会将
<c-tab>
(和其他类似<c-h>
的)发送到正在运行的程序。
看起来我的终端也同时阻塞了<C-tab>
和<C-;>
。重新映射使用<C-m>
,它仍然没有工作。那是因为它是一个插入模式映射,而我一直在尝试正常模式!