How to create a mapping for Insert mode but not for the autocomplete submode in Vim?

Viewed 1274

I have these insert mode mappings in my .vimrc file:

imap <C-e> <C-o>A
imap <C-a> <C-o>I

They make Ctrl-A and Ctrl-E move the cursor to the start and end of the line without leaving insert mode, a la emacs keybindings.

However, I just realized that the Ctrl-E mapping introduces a conflict with the autocompletion submode. The documentation in :help complete_CTRL-E states:

When completion is active, you can use CTRL-E to stop it and go back to the originally typed text.

Thus, my Ctrl-E mapping interferes with this. Is there a way that I can make Ctrl-E jump to the end of the line only if auto-completion is not active?

1 Answers
Related