为什么在 Vim 的插入模式下粘贴一个长的单行代码很慢? [英] Why is pasting a long one-liner very slow in Vim's insert mode?
问题描述
昨天我的 Macbook 卡住了,当时我试图将 1200 行 80 个字符的行粘贴到 Vim.下载文件要快得多,而不是粘贴文本.
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.
推荐答案
如果您将其粘贴到终端窗口中,Vim 会认为您正在手动输入它,并且会在您输入时尝试更新显示.您可以使用 pbpaste
和 pbcopy
命令访问剪贴板(在 OS X 上),因此您可以在 Vim 中执行此操作:
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
或在外壳中:
bash$ pbpaste | vim -
如果您使用的是 GUI 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
粘贴到终端窗口通常是个坏主意,请尽量使用 pbpaste
.
Pasting into the terminal window is usually a bad idea, try and use pbpaste
where you can.
这篇关于为什么在 Vim 的插入模式下粘贴一个长的单行代码很慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!