我在vim中使用supertab插件 这些是我的默认设置(在_vimrc中)
let g:SuperTabDefaultCompletionType = '<c-x><c-k>' -->(dictionary)
let g:SuperTabRetainCompletionDuration = "completion"
let g:SuperTabLongestEnhanced = 1
let g:SuperTabLongestHighlight = 1
我创建了这个脚本,以便在运行时选择带有supertab的omnicomplete:
function! SuperTabFunction()
if !exists("WhatSuperTab")
let WhatSuperTab = "SuperTab function?"
endif
if !exists("MenuSuperTab_choices")
let MenuSuperTab_choices = "&Current page\n&Spellchecker\nSentence\nCode"
endif
let n = confirm(WhatSuperTab, MenuSuperTab_choices, "Question")
if n == 1
let g:SuperTabDefaultCompletionType = '<c-x><c-m>'
so $VIM/vimfiles/plugin/supertab.vim
elseif n == 2
let g:SuperTabDefaultCompletionType = '<c-x><c-k>'
so $VIM/vimfiles/plugin/supertab.vim
elseif n == 3
let g:SuperTabDefaultCompletionType = '<c-x><c-l>'
so $VIM/vimfiles/plugin/supertab.vim
elseif n == 4
let g:SuperTabDefaultCompletionType = '<c-x><c-o>'
so $VIM/vimfiles/plugin/supertab.vim
else
return ''
endif
endfun
nmap <silent> <C-S-tab> :call SuperTabFunction()<CR>
imap <silent> <C-S-tab> <esc>:call SuperTabFunction()<CR>a
当我调用上面的函数并选择p.e. “句子” 我可以用超级标签来完成句子 当我再次调用上面的函数并选择p.e. “拼写检查程序” 正确的值分配给g:SuperTabDefaultCompletionType 但它仍然取代了句子。
这个功能我错了什么?
答案 0 :(得分:1)
您是否尝试过调用提供的函数而不是直接更改全局变量?
" SuperTabSetDefaultCompletionType(type) {{{ " Globally available function that users can use to set the default " completion type for the current buffer, like in an ftplugin. function! SuperTabSetDefaultCompletionType(type)