One of the reasons that I moved from emacs to vim was to avoid awkward keybindings such as Ctrl+N and Ctrl+P for up and down. I would prefer more ergonomic keys like hjkl. However, I didn't find a way to navigate in Omnicomplete box without using arrow keys or Ctrl+N/P.
Does vim provide other keys for up and down?
In the insert mode completion popup, any printable character is used to further restrict the list of matches, so there are only the <C-N>
/ <C-P>
keys to choose different menu items.
If you can live with losing some completion keys, you can define the following mappings:
:inoremap <expr> j pumvisible() ? '<C-n>' : 'j'
:inoremap <expr> k pumvisible() ? '<C-p>' : 'k'
I have the following mappings, which I'm very happy with:
" Move up and down in autocomplete with <c-j> and <c-k>
inoremap <expr> <c-j> ("\<C-n>")
inoremap <expr> <c-k> ("\<C-p>")
This is especially useful if you're using a plugin (such as Neocomplete, its older sibling Neocomplcache, or YouCompleteMe) that pops up autocomplete dialogues as soon as there might be something to complete to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With