All,

I decided to make a mapping that simply hits "<down>" whenever the popup
menu comes up. This is to make the popup behavior work more like in
IDEs, where the user can just select the nearest completion item at any
moment by hitting enter ("<c-y>" does this in Vim).

Here are two mappings I tried to accomplish my goal:

1. inoremap <c-n> <c-r>=pumvisible() ? "\<lt>c-n>" : 
"\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"<cr>
2. inoremap <expr> <c-n> pumvisible() ? "\<lt>c-n>" : 
"\<lt>c-n>\<lt>c-r>=pumvisible() ? \"\\<lt>down>\" : \"\"\<lt>cr>"

To me, they should be identical. However, the first doesn't work in some
circumstances, whereas the second always works. Specifically, #1 doesn't
work when the vim/gvim window is not large.

For those of you who like the idea, use mapping #2. Here are more ideas:
        set cot+=menuone,longest
        inoremap <expr> <cr> pumvisible() ? "\<c-y>" : "\<c-g>u\<cr>"

--Matt

Reply via email to