tags:

views:

137

answers:

2

Dumb question, right? Literally can't figure this out.

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

Is there a way around this?

+9  A: 

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.

pkaeding
To clarify, 'paste mode' turns off a lot of the auto-formatting and indentation features all at once, making it safe to paste large blocks of text without the content being munged.
Ether
Don't forget to check out 'pastetoggle', which makes it easier to do these to steps. For instance, I have:set pastetoggle=<Insert>This way before I paste text I just hit the <Insert> key. Then when I'm done I press it again. This is very convenient since I paste text with Shift-<Insert>
Neg_EV
+12  A: 

Or, to avoid having to turn paste on and off, just put the text. Rather than going into insert mode and pasting, in command mode type:

"+p

The + buffer corresponds to the system clipboard.

If you insist on using paste, I'd suggest mapping something to toggle it. For example, :set pastetoggle=<F2> (wow, didn't realize there was a special option for that)

Jefromi
there's also `set paste!`
rampion
+1 for mentioning the `+` buffer
jeffjose
@rampion: Yeah, that's what I originally mentioned, but took it out in favor of `pastetoggle`.
Jefromi
'pastetoggle' exists b/c you can't use an insert mode map to turn 'paste' back off--having 'paste' on disables on insert mode mappings.
graywh