Pasting into vim from GUI results in missing lines

10

0

When I copy text from an OS X GUI app (e.g. Firefox) and paste it into vim in my terminal, it's often missing the first few lines or characters, with no obvious pattern.

This may not be vim specific, but I've just tested pasting into the terminal when not using vim – e.g. when using the bash shell – and don't get them problem.

anon

Posted 2011-11-11T11:04:01.483

Reputation:

1Have you enabled insert mode before? – slhck – 2011-11-11T11:07:47.053

1(blush) Now you say it I'm not sure - maybe a simpleton like me should stick to the likes of nano. I'll answer my question myself to help future simpletons who'll doubtless Google something similar. – None – 2011-11-11T12:10:48.297

Low rep means I have to wait 8 hours so here's the answer I'll paste in then:

This was quickly answered in comments:

Have you enabled insert mode before? – slhck 1 hour ago

(blush) Now you say it I'm not sure - maybe a simpleton like me should stick to the likes of nano. I'll answer my question myself to help future simpletons [edit: no offence] who'll doubtless Google something similar. – tog22 just now

I presume this is the answer, and the lack of an obvious pattern was due to a lag in vim responding to the 'i' character being pasted in. – None – 2011-11-11T12:15:48.820

You can also use MacVim. It has better support for Mac OS X. – Eir Nym – 2011-11-11T13:22:29.097

Answers

13

Just make sure that when pasting to vim, the Insert Mode is activated. Do this by pressing i before pasting.

Otherwise pasted characters like i or o will trigger insert mode and you'll miss everything before.

slhck

Posted 2011-11-11T11:04:01.483

Reputation: 182 472

3You may also want to :set paste before pasting so that special indenting triggers don't affect the text you're pasting. When you've finished, :set nopaste to go back to ordinary behavior. – Mike Seplowitz – 2011-11-11T18:47:32.507