Say, I have the following
:nm <Plug>Ls :ls<CR>
:nm <Leader>L <Plug>Ls
When I do a ,L (,
being the leader), I do get the output of :ls
command. I also get the output when I do :normal ,L
, but I don't when doing the following
:normal <Leader>L
:normal <Plug>Ls
I can understand why the first isn't working, I suppose I have to do something like execute 'normal ' . mapleader . 'L'
. What I can't figure out is the second one. It doesn't give me any error, It just doesn't do anything, which is what driving me crazy. I couldn't find anything on this in the docs either.
What I want to do is run whatever is mapped to <Plug>Ls
, from the command mode (in a function actually). Any dark hacks needed for this?
They do work with normal, you just are not supplying it <Plug>
, you supply <
, P
, l
, u
, g
, >
. Correct syntax is
:execute "normal \<Plug>Ls"
Same applies to feedkeys()
: call feedkeys("\<Plug>Ls")
, not call feedkeys("<Plug>Ls")
.
Also note that execute "normal ".mapleader."L"
should not really be ever used as if mapleader
changes after you execute :nm <Leader>L <Plug>Ls
, then this :execute …
will try to call nonexistent mapping (mapleader
changes do not affect already created mappings). And you there are no ways to know whether mapleader
has changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With