Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do inline paste from system buffer in Vim?

Tags:

vim

When pasting from the system buffer in a line like

foo( someVal , <cursor is here>, someVal3); 

If I use "*p I get

foo( someVal, , someVal3);
<pasted text>

If I use "*P I get

<pasted text>
foo( someVal, , someVal3);

but I want

foo( someVal, <pasted text>, someVal3 );

How can I get the result I want?

edit

If there is a newline in the buffer as @amardeep suspects, is there a way I can tell vim to ignore it?

like image 347
µBio Avatar asked Jun 14 '10 20:06

µBio


People also ask

How do I copy and paste a line in Vim editor?

Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.

How do I enable copy and paste in Vim?

You can use :set mouse& in the vim command line to enable copy/paste of text selected using the mouse. You can then simply use the middle mouse button or shift insert to paste it. Save this answer.


1 Answers

You can type <C-r>* in insert mode and then use <BS> to remove trailing newline.

like image 103
ZyX Avatar answered Nov 01 '22 18:11

ZyX