Reputation: 744
I am trying to define a mapping to yank lines upwards without moving.
I need a mapping from y[Number]k
to :-[Number]y<CR>
.
For example, if i wanted to yank 6 lines upwards, i would type y6k
and it would be mapped to :-6,y
. Is this possible in vim?
Upvotes: 0
Views: 151
Reputation: 196496
Here is a possible solution:
nnoremap <expr> <key> ":\<C-u>-" . v:count1 . ",y\<CR>"
that lets you do {count}<key>
as if you did y{count}k
or :-{count},y
.
Upvotes: 2