Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In vim, if I've copied a line using 'yy', then 'p' will paste the copied text on a line below the cursor, and 'P' will paste the copied text to the line above the cursor... But how do I break the line where the cursor is AND paste the text there?

let's say I have this (the pipe char represents the cursor, not a character in the buffer):

ab|cd

I want a paste operation that will end me with:

ab
--Pasted Line--
cd

Basically, the end result would be the same as hitting "i<Enter>ESC" and then "P".

I actually just did this in vim accidentally, with one paste operation (without using i<Enter>ESC etc), but I'm not sure how I did it.

I know this question is similar to: http://stackoverflow.com/questions/1346737/how-to-paste-in-a-new-line-with-vim but it's different because I want to paste something copied using 'yy' and I also want to break the line at the point of the cursor, and paste the line where the new line break was just created.

share|improve this question

1 Answer 1

This appears to do that: move the cursor to the insertion point and type

vP

That pastes in visual mode. See

:help v_P

for more.

share|improve this answer
    
Close, but vP deletes the single character that is highlighted once the editor is in visual mode. Maybe (probably?) this is what I accidentally did, but it's not exactly what I want. –  Eddified Oct 20 '10 at 23:50
1  
Vim's registers can be tagged as linewise or characterwise. It seemed that maybe you wanted to yank linewise but paste characterwise. I was searching for a way to do that when I found vP. You could also try yanking with 0y$ which would yank the line characterwise, then paste it with p or P, but that doesn't seem like exactly what you want, either. –  garyjohn Oct 21 '10 at 0:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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