1

I use the following mapping to initiate keyword completion, followed by user defined completion:

inoremap <expr> <c-n> pumvisible() ? "\<c-x>\<c-o>" : "\<c-n>"

How can I rewrite this mapping so that repeatedly pressing <c-n> results in the cycling of keyword and user defined completion?

1 Answer 1

2

I'm not sure when exactly you would initiate the cycling (as you typically use <C-N> to both trigger and go through the list of matches), but the key to implementing this is via a boolean flag stored in a variable. To be able to use :let to toggle this, you need to move from an inline expression to a function (which still returns the chosen completion key).

inoremap <expr> <c-n> TriggerOrToggleCompletion()
function! TriggerOrToggleCompletion()
    ...
endfunction
1
  • I use <c-j> and <c-k> when pumvisble() to move through the list. I will look in to this, thank you.
    – user489
    Mar 18, 2015 at 14:53

Your Answer

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