2

I want to be able to:

:42y

then something like:

:13p

having it to paste the yanked line in a new line after 13, without taking my cursor away. So far, all solutions I have found involves going to the paste region, as calling

:13<ENTER>p

(or similar) - but then loosing the cursor position.

4

You can define your special version of "put" like this:

command! -bar -bang -range -register Put call append(<line2> - <bang>0, getreg(<q-reg>, 1, 1))

Now 13Pu works without any jumping around.

| improve this answer | |
  • It worked like a charm, because it IS a charm. Would you please expand on what this is doing? – fde-capu Dec 12 '19 at 18:03
  • @fde-capu Read :h :command, :h append() and :h getreg(). Basically, it's a new command which takes parameters (almost) like a regular :put, but calls append() to do the job. Of course, you can also call append() directly, but neither :call append(13, getreg("", 1, 1)) nor :call append(13, split(@@, "\n")) look particularly good. – Matt Dec 12 '19 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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