Search code examples
vimmacvimneocomplcache

NeoComplCache makes me an extra return key press to open a new line


The problem is that when I am at the end of the line, and the NeoComplCache prompt up some words. I want to open a new line below by pressing the return key, but I need to press the return key 2 times.

The first time of pressing the return key dismisses the prompt up, and the second time does the supposed job, opening a new line below.

End of the line with prompt up End of the line with prompt up

Press the return key 1 time 1 time

Press the return key 2 times 2 times

I think one of the solution is to disable the auto prompt up. But are there any solutions to solve this annoying problem?


Solution

  • Putting this in your .vimrc will cause one enter keystroke to close the popup and enter a newline:

    " <CR>: close popup and open a new line.
    inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
    function! s:my_cr_function()
      return neocomplcache#smart_close_popup() . "\<CR>"
    endfunction
    

    Or try one of the other snippets in this issue: https://github.com/Shougo/neocomplcache.vim/issues/88