I'm using AutoComplPop with omnifunc.
Rather than Enter auto-completing the selection in the autocomplete popup, I'd like to use Ctrl + Enter (or some other combination) and have Enter behave as usual.
That last point is important: if I want to insert a carriage return and the autocomplete popup has something highlighted, I'll have to hit enter twice.
So: how can I remap the autocompletion key?
I don't think that the AutoComplPop plugin does anything to the Enter key; rather, this is the default behavior when the completion popup is visible. See :h popupmenu-keys
:
The behavior of the <Enter> key depends on the state you are in: first state: Use the text as it is and insert a line break. second state: Insert the currently selected match. third state: Use the text as it is and insert a line break.
It's just that AutoComplPop by default selects the first match (which the built-in completions don't do).
To answer your question (though I don't fully get what behavior you want):
There's no special mode for the popup menu, you have to use a :help map-expr
and check for the popup menu with pumvisible()
. For example, to make <Enter>
abort completion and insert a line break:
:inoremap <expr> <CR> pumvisible() ? '<C-e><CR>' : '<CR>'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.