Michael Trojanek
Michael Trojanek

Reputation: 1953

How to use a plugin in a vi-mapping?

I'm using Tim Pope's vim-commentary plugin, loaded via pathogen.

Now I want <leader>yyp to copy a line of code and comment out the original. I can do this with the command yypkgccj in normal mode (gccis vim-commentary's default to comment out the current line) so I tried this mapping in my .vimrc:

nnoremap <leader>yyp yypkgccj

Does not work. However, this

nnoremap <leader>yyp yypk:normal gcc<cr>j

works.

This behaviour is the same with vim on OSX and Linux as well as mvim on OSX and gvim on Linux. Does anybody have an idea why I have to use the :normal command in my mapping?

Many thanks!

Upvotes: 0

Views: 79

Answers (1)

Kent
Kent

Reputation: 195269

if gcc is mapped, you want to reuse it in your new mapping, in this case, you could try: (without nore)

nmap <leader>yyp yypkgccj

Upvotes: 4

Related Questions