1

Basically what I want to do is running this key-binding:

nmap <Leader>= :[x digits]pu<CR>

My mapleader Leader is a space.

With the code above I want to paste the current string I have in the clipboard but by specifying the number line where I want to paste it.
For example, If I want to paste the current clipboard into the third line I would type:

:3pu

Or by using a shorcut with nmap:

nmap <Leader>= :3pu<CR>

So when I press space+= the vim command :3pu will be executed.

Nevertheless, what I want is to specify the number (with one digit or more) by using the nmap. For example, if I press 3+space+= then this command :3pu should run or If I press 14+space+= then this command should run: 14pu.

Is it possible to do that by using nmap? I've seen about using something like this:

nmap [Number]<Leader>= :pu<CR>

but I don't know how to detect what number I've pressed. I've read about using v.count though I was not able to detect with that the pressed number and add it before pu.

Btw, I'm using neovim for this (in case this matters).

2

1 Answer 1

2

The following works:

nnoremap <leader>= :<C-u>execute v:count 'put'<cr>

(you can probably also use <Cmd> instead of :<C-u>).

1
  • Thanks so much!! This really worked :D . Oct 20, 2022 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.