tags:

views:

575

answers:

8

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.

--edit

The text is: http://dpaste.com/115362/

+1  A: 

did you try paste mode? set paste / set nopaste?

ʞɔıu
No change: This is my paste: http://dpaste.com/115362/
Masi
+1  A: 

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).

Brian Rasmussen
This is not a mac issue. The same problem is in Ubuntu too.
Masi
Please, see the question. I clarified it.
Masi
The problem seems to be in pasting text which has no enters or spaces.
Masi
How can you have 1200 lines without enters?
Brian Rasmussen
Pasting your blob of text from the copy page of your link is still a snap in Vim on Windows. I would suspect the terminal then.
Brian Rasmussen
A: 

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...

GiDo
This is not the problem: the same problem is is Ubuntu too. Please, see the question again. I clarified it.
Masi
A: 

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.

Zsolt Botykai
It is not in the web. I edited it first by removing enters.
Masi
If it's not on the web then why not just did ':e /path/to/file'?
Zsolt Botykai
+3  A: 

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 -
dbr
+9  A: 

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.

too much php
+2  A: 

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

michael
A: 
:read !pbpaste

If you are using Linux use:

xsel --clipboard --output

or:

xclip -selection clipboard -o

instead of pbpaste.

datentyp