Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you paste with vim without code being commented?

Tags:

vim

Everytime I paste in vim, every line is commented out.

Is there a way around this?

like image 373
Trip Avatar asked Jul 09 '10 22:07

Trip


People also ask

How do I copy and paste in Vim without comments?

In Vim, the primary commands for yanking (copying) and putting (pasting) are y and p . Those commands are prefered to "Right-click/Paste or Middle Click or CTRL+SHFT+V" because the text is "put" into the buffer without any special treatment.

How do I paste without formatting in Vim?

vimrc so pressing F2 toggles paste on and off.

How do I paste contents in Vim?

You can use a movement command or up, down, right, and left arrow keys. 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 copy text and paste outside in Vim?

To copy selected text to system clipboard type "+y in Normal Mode. Now you can paste it anywhere else using Ctrl-v . To copy text from outside applications into Vim editor, first copy the text using the usual Ctrl-C command then go to Vim editor and type "+p in Normal Mode.


1 Answers

Before you paste, type this in normal mode:

:set paste 

Then enter insert mode. You will see the status bar say insert (paste). Paste your code. Hit ESC to return to normal mode, and:

:set nopaste 

You are no longer in paste mode.

like image 199
pkaeding Avatar answered Oct 09 '22 21:10

pkaeding