I'm using basic autocompletion in Vim along with the Autocomplpop plugin, which automatically shows available completions when I start typing. Once I've typed enough to narrow down the list to the word I want, I'd like to be able to hit tab to choose that completion. With the script below, two tab presses are required instead of one, and I'm not sure why.
" Tab completion " will insert tab at beginning of line, " will use completion if not at beginning set wildmode=list:longest,list:full 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> inoremap <S-Tab> <c-n>