Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is pasting a long one-liner very slow in Vim's insert mode?

Tags:

vim

paste

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.

like image 933
Léo Léopold Hertz 준영 Avatar asked Feb 01 '09 18:02

Léo Léopold Hertz 준영


People also ask

How do I get out of insert paste mode?

If you have an US English keyboard, pressing Ctrl - [ is equivalent for pressing Esc . This provides an easy way to exit from insert mode. Alternatively use Ctrl - c .


2 Answers

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.

like image 164
too much php Avatar answered Sep 23 '22 21:09

too much php


:read !pbpaste 

If you are using Linux use:

xsel --clipboard --output 

or:

xclip -selection clipboard -o 

instead of pbpaste.

like image 21
datentyp Avatar answered Sep 21 '22 21:09

datentyp