Vim inserting comments while copy pasting
Two main options:
- Put directly from the register without ever entering insert mode, using
"+p
-
"
means "use the following register"; -
+
refers to the clipboard, and -
p
for put!
-
Should you be using the middle click selection paste in Linux, use *
instead of +
to refer to it.
- Before entering insert mode to paste, run
:set paste
. Turn it off once you leave insert mode with:set nopaste
.
In Vim go to the mode :set paste
. Then press Ctrl + Shift + V.
It would work.
Don't paste by going to edit and paste. It won't work.
Everybody so far is missing the point. Vim is automatically inserting the comment field when you start a new line (whether it is from a paste or from your typing).
You have formatoptions set with at least the r and maybe the o option. To see your settings, type
:set formatoptions?
To remove those options, type
:set formatoptions=
Paste will then work the way you expect.
Type
:help fo-table
to see what the letters in formatoptions each mean.