I am using the autocomplete and I feel quite comfortable with it because it's minimalistic and simple. But there is just a thing I dislike: sometimes it interferes with the mouse scrolling auto-changing some word... Well, sometimes it also interferes when I jump from word to word in insert-mode, obligating me to undo the pop-up with direction keys...

Perhaps in this last weeks I am playing too much with vim, but my intention is to investigate the small plugin code to adjust it as my needs (if possible), enabling / disabling it depending if I am writing or not.

The pseudocode I thought is:

  1. Start typing or entering insert-mode, execute acp#enable()
  2. Stop typing or exit from insert-mode, execute acp#disable()

So is there any possible vim option that could enable it only when I am typing and disable after a short timeout when I stop/pause typing text ?

Is this too good to be true?


I just saw these interesting features:

                After a change was made to the text in the
                current buffer in Insert mode.
                Not triggered when the popup menu is visible.
                Otherwise the same as TextChanged.

                When a character is typed in Insert mode,
                before inserting the char.
                The |v:char| variable indicates the char typed
                and can be changed during the event to insert
                a different character.  When |v:char| is set
                to more than one character this text is
                inserted literally.
                It is not allowed to change the text |textlock|.
                The event is not triggered when 'paste' is

And help timeout.

  • 1
    I don't use this plugin and I'm really not sure what you want to do is a good idea (that look like a hacky trick which might cause more problems than it solves, but once again I don't use this plugin so I might be wrong). However you might also be interested in :h CursorHoldI.
    – statox
    Dec 20, 2017 at 14:44
  • Good to know this event. I actually set up an autocmd for InsertCharPre which calls acp#enable(), and other three autocmds for the events InsertLeave, CursorHold, CursorHoldI, and each one calls acp#disable(). Seems to be helpful !
    – xyx
    Dec 20, 2017 at 16:01

1 Answer 1


After having switched to gvim definetly since a few weeks, I think I have solved by my own:

 function! FeedCompletePopUp()
   if getline('.')[col('.') - 2] =~ '\w' && pumvisible() == 0
      return "\<C-N>\<C-P>"
      return ""


The following is taken and modified from acp plugin.

function AutoCompleteInoremap()
  let s:keysMappingDriven = [
        \ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
        \ 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
        \ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
        \ 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
        \ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        \ '-', '_', '~', '^', '.', ',', ':', '!', '#', '=', '%', '$', '@', '<', '>', '/', '\' ]
  for key in s:keysMappingDriven
    execute "inoremap <silent> <nowait> ".key." ".key."<c-r>=FeedCompletePopUp()<CR>"


inoremap <expr> <silent> <nowait> <Tab> pumvisible() ? "<C-N>" : "<Tab>"
autocmd VimEnter * call AutoCompleteInoremap()

Let's see if popup completition is not shown unintentionally...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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