34

How can I paste some text that I yanked at the end of the line? Currently I'm doing it by pressing $p. Is there any way to do this with a single keystroke?

  • 2
    Thank you, $p is already better than A<esc>p that I was currently using. – 79E09796 Oct 20 '15 at 20:09
  • 3
    You know you're using vim too much when you think of 2 keystrokes as "too much of a hassle." – RichouHunter Aug 16 '17 at 15:32
23

There is if you create a mapping, e.g..

:nmap , $p

Then you can type , to paste at the end of the line.

Remember, one way or another, you'd have to tell Vim that you want the text at the end of the line, and not where the cursor currently is; by default, Vim has no single key-stroke for this.

2

A couple more keystrokes, but will allow you to position the text or add other content before pasting:

a

<position the cursor where you would like to paste the text>

Ctrl+r"

Explanation: Ctrl+r inserts the contents of a register. " is the unnamed register, containing the text of the last delete or yank.

I find myself doing this a lot when pasting comments. :)

  • 1
    This doesn't answer my question at all. I'm looking for economy in keystrokes, and you're suggesting something that costs more. – Nathan Fellman Aug 21 '17 at 19:29

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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