Question

Somehow my macvim/vim instance is expanding every tab to the autocomplete menu, this prevents me from tabbing my code.. I really dont have a clue about the why.

My vimrc is here: https://github.com/jvanbaarsen/dotfiles/blob/master/vimrc

a screenshot of the problem:

(the "happens" text, is the first appearance in the autocomplete list, i tabbed on a newline though)

I hope someone can help me, this is driving me insane!

Was it helpful?

Solution

I had found this online and used it in my vimrc to "fix" the problem. But it was still kinda a pain, so I just retrained myself to use ctrl-p. not the url in the comment was valid at one time, but is not longer..

" Remap the tab key to do autocompletion or indentation depending on the
" context (from http://www.vim.org/tips/tip.php?tip_id=102)
function! InsertTabWrapper()
  let col = col('.') - 1
  if !col || getline('.')[col - 1] !~ '\k'
    return "\<tab>"
  else
    return "\<c-p>"
  endif
endfunction
inoremap <silent> <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>

OTHER TIPS

I think i found the problem, it was the 'ervandew/supertab' bundle, after removing it, i was able to use vim normally.

The supertab plugin aims at both keeping usual indentation functionality of <Tab> key and completing with it. I personally don’t use it using self-written function instead, but possible causes of your issue are described in the very first question in the FAQ placed in the README file available right at project homepage:

  • Why isn't supertab honoring my configured settings (attempts to complete at the start of a line, always performs keyword completion instead of my configured default, etc.)?

    Chances are that you have a very old version of snipmate installed, or something similar, which will issue a <c-n> when no snippet is found. Supertab use to map to <c-n>, so this behavior would act as a fallback to supertab, but current versions of supertab no longer do so, resulting in snipmate bypassing supertab entirely.

    You can check if this is the case by running the following in vim to see what is mapped to <tab>:

     :verbose imap <tab>
    

    To resolve the issue you can either:

    1. Install my fork or
    2. Upgrade to a more recent snipmate fork, like garbase/vim-snipmate

    See #74 for additional details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top