[vim] test out tab autocompletion in insert mode
change
commit 958f3abdb6ecf47c062ada431a4833d844d6ce47
author Alpha Chen <alpha@kejadlen.dev>
date
parent cbb6ef51
diff --git a/.vimrc b/.vimrc
index d3d4c984..0753037f 100644
--- a/.vimrc
+++ b/.vimrc
@@ -115,6 +115,16 @@ 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 "\<C-N>"
+  else
+    return "\<Tab>"
+  endif
+endfunction
+inoremap <tab> <c-r>=TabOrComplete()<cr>
+
 " }}}
 
 " GUI {{{