1

Using: NeoVim

I would like to remap j/k in Insert completion mode:

  • tab starts autocompletion (done, used :help ins-complete example)
  • j/k navigate results like <C-n>/<C-p>

If I understand correctly the Insert completion mode simply shares rebinds with the normal Insert mode, so there's no inoremap equivalent (i.e. pnoremap for comPlete). So is there some way of doing this?

I would prefer not to use a plugin. A best case solution would not break my existing inoremap jk <esc> binding, but I would also be interested in solutions that break that.

1 Answer 1

3

Something like the following should work and still allow your jk to function:

imap <expr> j pumvisible() ? "\<C-n>" : 'j'
imap <expr> k pumvisible() ? "\<C-p>" : 'k'
2
  • On my install (NVIM v0.9.2) pumvisible() returns v:null when called. So these keymaps won't work. Is there an alternative to pumvisible in newer versions?
    – hmaier
    Aug 27, 2023 at 15:40
  • @hmaier that sounds like a bug unless you can point me to intentional docs where they changed it…
    – D. Ben Knoble
    Aug 27, 2023 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.