diff --git a/.vimrc b/.vimrc index 737cab8..dcf6afb 100644 --- a/.vimrc +++ b/.vimrc @@ -115,15 +115,20 @@ augroup DisableAutoComment autocmd BufEnter * setlocal formatoptions-=o augroup END -" https://vim.fandom.com/wiki/Autocomplete_with_TAB_when_typing_words -function! TabOrComplete() - if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' - return "\" - else +" :help ins-completion +function! CleverTab() + if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$' return "\" + + " https://vim.fandom.com/wiki/Smart_mapping_for_tab_completion + elseif exists('&omnifunc') && &omnifunc != '' + return "\\" + + else + return "\" endif endfunction -inoremap =TabOrComplete() +inoremap =CleverTab() " }}}