Added smart mapping for tab-completion

via http://vim.wikia.com/wiki/Smart_mapping_for_tab_completion
This commit is contained in:
Nick Nisi
2012-11-13 07:46:05 -06:00
parent 42c5eae49d
commit 614cb0642b

View File

@@ -288,6 +288,28 @@ function! ApplyLocalSettings(dirname)
endfunction
autocmd! BufEnter * call ApplyLocalSettings(expand("<afile>:p:h"))
" smart tab completion
function! Smart_TabComplete()
let line = getline('.')
let substr = strpart(line, -1, col('.')+1)
let substr = matchstr(substr, "[^ \t]*$")
if (strlen(substr) == 0)
return "<\tab>"
endif
let has_period = match(substr, '\.') != -1
let has_slash = match(substr, '\/') != -1
if (!has_period && !has_slash)
return "\<C-X>\<C-P>"
elseif (has_slash)
return "\<C-X>\<C-F>"
else
return "\<C-X>\<C-O>"
endif
endfunction
inoremap <tab> <c-r>=Smart_TabComplete()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""