You can use the more powerful "expression mappings":
:inoremap <expr> <silent> <Up> pumvisible() ? "\<Up>" : "\<C-o>gk"
:inoremap <expr> <silent> <Down> pumvisible() ? "\<Down>" : "\<C-o>gj"
Note that we added the <expr>
keyword here. Now Vim expects that the right-hand is some (valid) VimScript codeexpression. The codeThis expression is evaluated every time the key is pressed and the result is used as the action.
Here we use the pumvisible()
function (short for "pop-up menu visible") to check if the popup menu is visible. If it is, just go up/down. If it isn't, use your special mappings.
Also see :help :map-expression
.
Expression mappings were introduced with Vim 7, which was released in May 2006 (after the mailmaillist post you linked to), which is probably why no one mentioned itthis as a solution thenback then :-)