When I try to paste hundreds of lines or more into Vim, even in paste mode, it takes much longer (10 times or more?) than to paste that same text into TextEdit and save it as a file. I would speculate that Vim is trying to insert one character at a time and that this is slowing things down. When it's quite a large paste, I end up having to save the text with TextEdit and then open it up in Vim. Is there a faster way to paste text in?
If your Vim is compiled with clipboard support (:echo has('clipboard') returns 1) you can simply use "+p or "*p.
If it's not (:echo has('clipboard') returns 0), get yourself a proper Vim. On Mac OS X, MacVim is the way to go.
I would speculate that Vim is trying to insert one character at a time and that this is slowing things down.
This is correct. Given how terminal works, it can't go any other way. Use GVim/MacVim in GUI mode, and the problem should go away.
Alternately, you can use terminal commands to speed things up. For example, on a Mac, you can do
:r!pbpaste
to paste whatever is in your clipboard below the current line. Vim is getting its input from the pbpaste command, not the terminal, so it avoids the terminal's one-character-at-a-time thing. If you're on Linux, see What's like OSX's pbcopy for Linux.
Another avenue of approach is to see where the hundreds of lines are coming from. If it's from another file, load it into a Vim buffer, then use Vim's native copy-paste (y, p). If it's an output from a command, consider redirecting the command's output to a file first. If it's a webpage, curl it. Clipboard and copy-paste don't really figure into the original terminal-based workflow; pipes and files do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With