views:

39

answers:

1

Omnicompletion works pressing <C-X><C-O> making a dropdown list appear. I wanted to map it as <S-Tab> <C-X><C-O> but first I wanted to test it as: <C-F5> <C-X><C-O>. It does complete the word but the dropdown list doesn't show up. (the same happens with the plugin SuperTab).

Any suggestions?

EDIT: *it Works* like this inoremap <S-F5> <C-X><C-O> but it doesn't work like this inoremap <Tab> <C-X><C-O> or <TAB> <C-X><C-O>

CODE:

" autocomplete using tab
imap <C-F5> <C-X><C-O> 
+2  A: 

One day, I found this (probably on vim.org):

fu! InsertTabWrapper(direction)
  let char_before = col('.') - 1
  if !char_before || getline('.')[char_before - 1] !~ '\k'
    return "\<tab>"
  elseif "backward" == a:direction
    return "\<c-p>"
  else
    return "\<c-n>"
  endif
endfu

inoremap <tab> <c-r>=InsertTabWrapper("forward")<cr>
inoremap <s-tab> <c-r>=InsertTabWrapper("backward")<cr>

And it works like a charm.

Oli

related questions