How can I paste something at the end of the line in VIM?

36

5

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?

Nathan Fellman

Posted 2010-03-18T11:51:33.060

Reputation: 8 152

3Thank you, $p is already better than A<esc>p that I was currently using. – 79E09796 – 2015-10-20T20:09:21.803

4You know you're using vim too much when you think of 2 keystrokes as "too much of a hassle." – RichouHunter – 2017-08-16T15:32:46.440

Answers

25

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.

njd

Posted 2010-03-18T11:51:33.060

Reputation: 9 743

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. :)

Foolish Brilliance

Posted 2010-03-18T11:51:33.060

Reputation: 121

1This doesn't answer my question at all. I'm looking for economy in keystrokes, and you're suggesting something that costs more. – Nathan Fellman – 2017-08-21T19:29:55.160