Created
December 5, 2012 15:08
-
-
Save inside/4216245 to your computer and use it in GitHub Desktop.
Vim tab map for completion
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
" This can conflict with the default mappings provided by snipmate. | |
" See the after directory in .vim/bundle/snipMate/after | |
function! SuperCleverTab() | |
if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$' | |
return "\<Tab>" | |
elseif pumvisible() | |
return "\<c-n>" | |
else | |
if &omnifunc != '' | |
return "\<C-X>\<C-O>" | |
elseif &dictionary != '' | |
return "\<C-K>" | |
else | |
return "\<C-N>" | |
endif | |
endif | |
endfunction | |
" <C-R> explained: | |
" You can insert the result of a Vim expression in insert mode using the <C-R>= | |
" command. For example, the following command creates an insert mode map command | |
" that inserts the current directory: | |
" :inoremap <F2> <C-R>=expand('%:p:h')<CR> | |
inoremap <Tab> <C-R>=SuperCleverTab()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment