I want to be able to:


then something like:


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


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


1 Answer 1


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.

  • 1
    It worked like a charm, because it IS a charm. Would you please expand on what this is doing?
    – fde-capu
    Dec 12, 2019 at 18:03
  • 1
    @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, 2019 at 18:34

Your Answer

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

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