在 vim 中编辑时,我想在我的 markdown 文件中植入一些@tags
(例如@sea_ice
, )。@models
目前我正在使用 SuperTab 来完成普通单词。但是,如果我<tab>
在@
符号后面点击,它不会给我一个 all 的列表@tags
,而是一个在当前上下文中找到的所有单词的长列表。
我注意到 SuperTab 允许自定义上下文定义,但是,由于我对 vim 脚本一无所知,并且文档仅包含 2 个示例,因此我无法自己编写脚本。
经过一番搜索,我想我可能需要定义一个新的自定义全功能完整函数,特别是函数的第二半:
function! TagComplete(findstart, base)
if a:findstart
" locate the start of the word
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] != '@'
let start -= 1
endwhile
return start
else
" find @tag
let res = []
????
????
endif
return res
endif
endfun
这是我正在处理的代码。但我不知道如何测试它,也不知道在哪里放置它。请帮忙
谢谢