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?
3 Answers
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"...
-
-
Because I feel that Jim's answer is correct, this is a bug. There's no reason one should need to turn syntax highlighting off for a simple copy-paste to work smoothly like it does in gedit, etc. Just seems that the bug depends on the syntax highlighter extension, not base vim.– cboettigOct 22, 2014 at 3:19
-
1Who is then that cboettig that wrote: So, current answer is "turn off syntax highlighting"... :-). I'm being sarcastic of course but don't get me wrong, I'm just noting the contradiction. Anyway after investigating a bit more I thing that the evilsoup's answer is even more to the point. See also stackoverflow.com/questions/18258561/…– ndemouOct 22, 2014 at 6:41
-
This may also be caused by
foldexpr
. When I'm pasting into markdown, just disabling syntax doesn't help. I've documented a fix in this answer: stackoverflow.com/a/61694190/3407728 May 9, 2020 at 9:02
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
.
-
...Unless your vim doesn't support
”+
, like the Mac default version. (: Jun 28, 2018 at 18:48
You should probably file a bug report against vim on this one.
-
2okay, thanks. I've posted my bug to [email protected] as suggested here: vimdoc.sourceforge.net/htmldoc/intro.html, we'll see if anything happens.– cboettigNov 26, 2012 at 5:12