vim struggles when copy-pasting large blocks of text in from an external window

I select and copy a large block of plain text from some file (e.g. gedit). I run :set paste and then enter insert mode, and paste the text in using the right mouse-button menu. vim them uses 100% cpu for the next several minutes before successfully pasting my text in. The text is usually only a few pages, and takes less than a second to paste into other applications (gedit window, web window, etc). What is vim doing with all those clock cycles and how can I make this more efficient?


Based on a suggestion from the maintainer after filing a bug report, it seems this problem is caused by the syntax highlighter. Disabling syntax highlighting temporarily (:set syntax=off) fixes this, though having to do both that and :set paste, and then toggle each back again is rather annoying (yes, I know I could map the commands in .vimrc. It is still annoying). Pasting also runs faster in gvim than in vim. Not sure why.

So, current answer is "turn off syntax highlighting"...


The correct way to paste text in vim is with the p command (from normal mode).

To paste from the xclipboard (the 'middle-click' clipboard), you should use "*p. To paste from the Ctrl+v clipbaord, use "+p.


You should probably file a bug report against vim on this one.