I recently changed my arrow keys to map to no-op to force myself to use vim navigation properly. When using word completion in vim a word-list of possible completions pops up. I used to navigate this by using the arrow keys, but now have to use the same mapping as the completion initiation to iterate through.
When this menu pops up, does vim stay in insert mode, change to a different mode or does it enter a modified insert mode (similar to what paste-toggle does) that I can alter the j
and k
mappings to move through the list?
If not is there a way of calling a method on pop-up open and close?
vim has two "modes": COMMAND mode and INSERT mode. In COMMAND mode, you execute commands (like undo, redo, find and replace, quit, etc.). In INSERT mode, you type text. There is a third mode, VISUAL mode, that is used to highlight and edit text in bulk.
By default, Vim starts in “normal” mode. Normal mode can be accessed from other modes by pressing Esc or <C-[> .
The popup menu of insert mode completion candidates belongs to insert mode, there's no special submode for it. To differentiate, you have to use map expressions :inoremap <expr>
with a condition on pumvisible()
. E.g. to remap j
to select the next completion candidate:
:inoremap <expr> j pumvisible() ? '<C-n>' : 'j'
Note that with this, you won't be able to type candidate names containing j
to drill down and select from the list (which is especially useful with :set completeopt+=longest
).
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