我正在使用Vim的Utl插件,並且正在尋找一種創建自定義自動完成功能的方法,以生成指向文件中id標籤的鏈接。我想要使用的格式是:Vim的自定義自動完成中的文件列表
:CommandName <file> <id tag in file>
我希望該函數的行爲像第一個參數的標準目錄完成。對於第二個參數,我希望它搜索第一個參數中指定的文件,以「id =」開頭的所有字符串並返回值。
我已經複製了類似的功能出主UTL包,但我還沒有親近使其工作,但目前看起來是這樣的:
fu! CompleteArgs(dummy_argLead, cmdLine, dummy_cursorPos)
" Split cmdLine to figure out how many arguments have been provided by user
" so far. If Using argument keepempty=1 for split will provide empty last
" arg in case of a new arg is about to begin or an non empty last argument
" in case of an incomplete last argument. So can just remove the last arg.
exe "echo \"cmdline:\" \"".a:cmdLine."\""
let utlArgs=split(a:cmdLine, '\s\+', 1)
execute "echo" string(utlArgs)
echo "echo" "test complete"
"remove the function name
call remove(utlArgs, -1)
" 1st arg to complete
if len(utlArgs)==1
return string(glob("*"))
endi
" 2nd arg to complete
if len(utlArgs)==2
"insert code here
endif
endfun
有沒有人有什麼想法?
謝謝,這幾乎是完美的。 – Sparky