I've noticed that when using the complete() function if I backspace out of it, vim will go into "Whole line completion" mode. This is very frustrating as it makes things very sluggish when working with big files. Worse yet, I don't know of a good way to get out of that mode aside from backing out to normal mode. :h complete_CTRL-E says to use <C-e> to get out and return to the original text, but that will actually delete the rest of the line in my case. I've prepared an MCVE to demonstrate:

set backspace=2

autocmd CursorMovedI * call CheckConversions(expand('<cword>'))

function! CheckConversions(word)
   let firstColumn = col('.') - strlen(a:word)
   if (a:word =~ '\<foo')
      call complete(firstColumn, ['foo', 'foobar', 'foobarbar'])

Try typing "bar foo". The completion popup shows up. So far so good. Now backspace. The popup goes away and now -- Whole line completion (^L^N^P) Back at original shows at the bottom. Now press <C-e>. The whole line is now replaced with "fo".

I can't figure out why "Whole line completion" mode is even starting in the first place! Is this a bug, or is this somehow intended? I'd like to either not trigger this mode, or have a good way of getting out of it without having to leave insert mode.

Context to avoid XY problem: I'm writing a plugin that will detect when typing numbers and automatically give base conversion suggestions in the complete() menu. I've got it working pretty well except for this annoying bug that makes backspacing a pain.

Edit: Version is: 7.4.0. Tested using gVim and vim on Windows.

Edit2: Guess I'll try on vim_dev. I'll update here if I find anything out.


This is a bug but it has already been fixed. I'm not sure exactly which patch it was fixed in but it at least is gone in v.7.4.2196.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.