Skip to content
Browse files

Implement a smarter tab completion function

Credit: Gary Bernhardt
  • Loading branch information...
1 parent 397312e commit 5a4eb4661ba01e3a47512622c3b9d26f0f59fc33 @wordofchristian wordofchristian committed with croaky Oct 29, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 vimrc
View
12 vimrc
@@ -65,9 +65,19 @@ set numberwidth=5
let g:snippetsEmu_key = "<S-Tab>"
" Tab completion
+" will insert tab at beginning of line,
+" will use completion if not at beginning
set wildmode=list:longest,list:full
set complete=.,w,t
-imap <Tab> <C-P>
+function! InsertTabWrapper()
+ let col = col('.') - 1
+ if !col || getline('.')[col - 1] !~ '\k'
+ return "\<tab>"
+ else
+ return "\<c-p>"
+ endif
+endfunction
+inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
" Exclude Javascript files in :Rtags via rails.vim due to warnings when parsing
let g:Tlist_Ctags_Cmd="ctags --exclude='*.js'"

0 comments on commit 5a4eb46

Please sign in to comment.
Something went wrong with that request. Please try again.