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
    Does this answer your question? Fix indentation in a file while keeping cursor on the same line
    – Matt
    Commented Dec 11, 2019 at 19:11
  • There are definitely versions of this question elsewhere. Hmm.
    – D. Ben Knoble
    Commented Dec 11, 2019 at 19:39
  • @Matt, that is what I don't want: to move on then move back. Since I am able to yank without changing position, I would also like to paste.
    – fde-capu
    Commented Dec 11, 2019 at 19:54

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
    Commented 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
    Commented 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.