Reputation: 13
I want to map some combinations. I have been reading :h map
for a long time, but I still don't understand how to map "d" and "y" so that they do the following things ({ }
is optional):
d{count}{movment} => "_d{count}{movment}
{"reg}<Leader>d{count}{movment} => {"reg}d{count}{movment}
I want d
to really delete text, so that the familiar d3d
, d3w
, diw
, etc will really delete text too. <Leader>d
to cut into register "1
(if not specified) or into specific register.
y{count}{movment} => y{count}{movment} call my_func()
"reg y{count}{movment} => "reg y{count}{movment}
Same thing with y
, but here y{count}{movment}
must copy and call my function. And "reg y{count}{movment}
just should work as usual.
I wish it would work visual and normal mode.
Upvotes: 1
Views: 140
Reputation: 15186
This is evil and should not be done. It only makes sense if you seek for personal "challenge", yet in this case you'd better figure it yourself. But if you still need a hint, I'd probably started with :h 'opfunc'
That is easily achievable if your Vim is modern enough (8.1+). Simply catch :h TextYankPost
and do your stuff from there.
Upvotes: 1