Created
August 25, 2014 01:04
-
-
Save bernardeli/875a3451c6273ae91b09 to your computer and use it in GitHub Desktop.
clever-tab.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! CleverTab(type) | |
if a:type=='omni' | |
if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$' | |
let g:stop_autocomplete=1 | |
return "\<TAB>" | |
elseif !pumvisible() && !&omnifunc | |
return "\<C-X>\<C-O>\<C-P>" | |
endif | |
elseif a:type=='keyword' && !pumvisible() && !g:stop_autocomplete | |
return "\<C-X>\<C-N>\<C-P>" | |
elseif a:type=='next' | |
if g:stop_autocomplete | |
let g:stop_autocomplete=0 | |
else | |
return "\<C-N>" | |
endif | |
endif | |
return '' | |
endfunction | |
inoremap <silent><TAB> <C-R>=CleverTab('omni')<CR><C-R>=CleverTab('keyword')<CR><C-R>=CleverTab('next')<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment