1

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.

1

Sorry I figured out the problem. We simply shouldn't use noremap configuration when dealing with <Plug>. Changing the map back to imap would work.

1
  • also available for <C- + nonliterals. example: <C-_> which means control+backslash – alexzander Jun 12 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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