2011-11-29 44 views
1

我在vim中使用supertab插件。
這些都是我的默認設置(_vimrc)使用supertab動態更改omnicomplete

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. 「Spellchecker」 將正確的值分配給g:SuperTabDefaultCompletionType 但它仍替換句子。

這個功能我錯了什麼?

回答

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)