This happens because the <Plug>
command is itself a mapping defined by a plug-in, so you need recursive mappings in this case for it to work.
imap <a-1> <ESC><Plug>AirlineSelectTab1
The usual recommendation is to always use the nore
(non-recursive) version of map commands, to prevent interference from mappings created by the user or by other plug-ins, but unfortunately that's not really possible with commands that use <Plug>
mappings.
An alternative, to minimize the number of keystrokes where you're considering recursive mappings (and can maybe help with <Plug>
commands that are a whole prefix for another <Plug>
command, surely a bad practice but you might find them) is to use :normal
(not :normal!
, which doesn't consider mappings) from your mapping expansion. That also requires using :execute
and marking the mapping as <silent>
so it doesn't prominently display the Ex command line during execution.
inoremap <silent> <a-1> <ESC>:execute "normal \<Plug>AirlineSelectTab1"<CR>
That's probably not worth it for a simple case like this one, but might be relevant for more complex mappings that involve many keystrokes other than the call to the <Plug>
command itself.