Shougo / neocomplcache.vim

Ultimate auto-completion system for Vim.
http://www.vim.org/scripts/script.php?script_id=2620
1.72k stars 135 forks source link

<C-e> and <C-y> conflict (insert mode) #440

Closed aymericbeaumet closed 11 years ago

aymericbeaumet commented 11 years ago

I encounter a problem while typing <C-e> or <C-y> in insert mode.

When I activate neocomplcache, I have to type <C-e> or <C-y> two times to do the expected behavior.

How can I fix this?

Shougo commented 11 years ago

Please read documentation.

    inoremap <expr><C-y>  neocomplcache#close_popup()
    inoremap <expr><C-e>  neocomplcache#cancel_popup()
aymericbeaumet commented 11 years ago

I read the documentation and I tried what you mentionned, but it totally disable <C-y> and <C-e> behavior in insert mode.

Shougo commented 11 years ago

It totally disable and behavior in insert mode.

You can custom these mappings.

aymericbeaumet commented 11 years ago

I understand that I have to rebind these keys, but I can't find how to restore the default vim behavior,

Ferreus9001 commented 11 years ago

I have the same problem here. It turns out that closing an open popup actually is the default behavior for those keys. See help tags complete_CTRL-E and complete_CTRL-Y.

aymericbeaumet commented 11 years ago

Thanks for you answer @Ferreus9001.

In insert mode, I expect this behaviour:

  1. Pressing <C-y> copy the character from the above line
  2. If needed, show to completion popup
  3. Pressing <C-y> again will close the completion popup and copy the character from the above line
  4. If needed, show to completion popup
  5. etc...

The below code closes the completion popup:

inoremap <expr><C-y>  neocomplcache#close_popup()
inoremap <expr><C-e>  neocomplcache#cancel_popup()

How to do the other actions?

Ferreus9001 commented 11 years ago

I think i found a solution:

inoremap <expr> <C-y> pumvisible() ? "\<C-y>\<C-y>" : "\<C-y>"
inoremap <expr> <C-e> pumvisible() ? "\<C-y>\<C-e>" : "\<C-e>"

Note that the popup is always closed with <C-y> or it won't work.

aymericbeaumet commented 11 years ago

Unfortunately it doesn't work for me... When I use your binds and type <C-y> in insert mode, I really write <C-y> in the editor. Does this solution work for you?

aymericbeaumet commented 11 years ago

Hum it works, I found the problem. In my vim version (7.3) the cpoptions option causes a problem. When I removed it, everything worked fine!