I have the following configuration in my vimrc file.

inoremap <C-A> <Plug>InsertComment

And somewhere in my vim folder I defined

inoremap <silent> <Plug>InsertComment <ESC>:call INSERT_MY_COMMENT

The mapping worked really well after I configured it. But somehow recently it stopped functioning. And whenever I can to use the Key-bind in the insert mode, instead calling the function that I mapped, vim will just paste the entire <Plug>InsertComment thing to my buffer.

I tried to debug and found out that if I map

inoremap <C-A> <ESC>:call INSERT_MY_COMMENT

it still works as desired, which means there must be something wrong with the <Plug> part.

But I really have no clue on why <Plug> would stop being interpreted by vim as a handle to call other plugins.

I also tried to manually copy and paste

inoremap <silent> <Plug>InsertComment <ESC>:call INSERT_MY_COMMENT
inoremap <C-A> <Plug>InsertComment

in to vim's command line, just to make sure the configurations have not accidentally been unset. But still, vim wouldn't accept that as a function, but rather copy the plain text to buffer.

2 Answers 2


If you use a nore mapping to tie a sequence of keys to <plug>something, even if there is a mapping behind that <plug>something, it'll be ignored. In the documentation, nore is said to prevent recursion. That's what is happening here.

That means that: the <plug>something mapping shall indeed be defined with noremap, but the actual keybinding chosen shall not.

IOW, the correct definitions become

" in a plugin: 
inoremap <silent> <Plug>InsertComment <c-o>:call INSERT_MY_COMMENT()<cr>

" in your .vimrc
imap <C-A> <Plug>InsertComment

Your problem is that you are using

inoremap <C-A> <Plug>InsertComment

That basically means, that recursive resolution of your mapped keys is prevented which is usually not what you want. Therefore change your mapping to

imap <C-A> <Plug>InsertComment

See also the extensive help

(Start reading from the paragraph that starts with MAPPING)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.