lsund
lsund

Reputation: 744

Map letter-number combination into command in vim

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

Answers (1)

romainl
romainl

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

Related Questions