Reputation: 141110
My Macbook was stuck yesterday, when I tried to paste 1200 lines of 80 characters to Vim. It was much faster to download the file, and not to paste the text.
I have thought that this problem might be the reason, why internet operators allow slower uploading than downloading.
Upvotes: 29
Views: 9548
Reputation: 179
I favor set paste/nopaste like Masi suggested. In .vimrc, you can map some character to toggle paste (if often needed).
i.e.
set pastetoggle=§
Upvotes: 3
Reputation: 1381
:read !pbpaste
If you are using Linux use:
xsel --clipboard --output
or:
xclip -selection clipboard -o
instead of pbpaste.
Upvotes: 22
Reputation: 51593
But if it's on the web, you should have tried:
:e http://link/to/file
Then if necessary save it as a local file.
And if it's slow because of the redrawing, look at this option:
*'lazyredraw'* *'lz'* *'nolazyredraw'* *'nolz'*
'lazyredraw' 'lz' boolean (default off)
global
{not in Vi}
When this option is set, the screen will not be redrawn while
executing macros, registers and other commands that have not been
typed. Also, updating the window title is postponed. To force an
update use |:redraw|.
And if it's a local file, then pasting is not necessary: try
:read file
instead.
Upvotes: 1
Reputation: 90988
If you paste it into a terminal window, Vim thinks you're typing it out by hand, and it will try and update the display as you go. You can access your clipboard (on OS X) using the pbpaste
and pbcopy
commands, so you can just do this in Vim:
:read !pbpaste
or in a shell:
bash$ pbpaste | vim -
If you were using GUI Vim, you would use the "*
register to paste (this is what the context menu does):
"*P <- in normal mode
Pasting into the terminal window is usually a bad idea, try and use pbpaste
where you can.
Upvotes: 46
Reputation: 11847
if you :syntax off you can sometimes improve an in place paste of a long single line file. An example would be a machine generated xml file.
you can probably disable vim's redraw whilst pasting as well, look at :he redraw , but it's always worth using command line stuff as If you are repeating the procedure or similar you can always automate it with a script / vim macro
Upvotes: 2
Reputation: 169543
That is "normal". It's slow because redrawing the text thousands of times is slow.
As you paste the long line in, it's constantly update the display (because of how vim deals with text, or how the terminal is handing vim text, I guess).
I tried pasting the text in vim (using iTerm) and it has the same issue, it takes a while to paste. I tried :set paste
and :set nowrap
and still as slow. Pasting the line straight into a terminal is equally slow
With the dpaste link you mention, there is a plain-text link, which you could just wget and edit:
curl http://dpaste.com/115362/plain/ | vim -
Upvotes: 6
Reputation: 1330
If you use Apple Terminal try an other terminal, like iTerm. Sometimes, the "build-in" terminal is not really reactive for common task. Don't know why...
Upvotes: 0
Reputation: 116401
I don't know if this is a Mac issue or something else, but I have no problems whatsoever with pasting that amount of text in Vim. I have tried on Windows and Linux, and haven't seen any problems.
I have successfully edited files of several hundred megs (log files) in Vim (loading is slow, but once the text is read everything is pretty snappy).
Upvotes: 1