1

我想将 web 上的内容粘贴到 vim 中。

1.选择我要粘贴的内容。
请附上

在此处输入图像描述

2.我用方法剪贴板粘贴的句子2

在此处输入图像描述 在此处输入图像描述

3.比较我粘贴的句子2与:+p 在此处输入图像描述 为什么句子1丢失字母的方法C?这是唯一不同的地方。

4

2 回答 2

6

当你使用 时"+p,vim 会粘贴+缓冲区的内容。但是,当您从剪贴板粘贴时,终端仿真器会将 vim 每个字母作为输入传递,就好像来自键盘一样。碰巧您粘贴的内容的第一个字母是C,这会导致 vim 从光标剪切到行尾并进入插入模式,因此您只会丢失一个字符。从剪贴板粘贴时(通过菜单或 ctrl-v),您需要先进入插入模式。并且根据您要粘贴的内容,您可能需要:set paste, 以防止绑定和格式化生效(用于:set nopaste将其关闭)。

于 2013-05-26T03:41:55.263 回答
0

通常,您不希望 Vim 解释您从系统剪贴板粘贴的任何内容,而只解释键入的文本。然而,Vim 无法在所有场景中知道粘贴文本和键入文本之间的区别,尤其是在终端中。使用粘贴模式将禁用对粘贴文本的任何解释,即格式化、插件自动完成甚至命令。

来自:h paste

        Put Vim in Paste mode.  This is useful if you want to cut or copy
        some text from one window and paste it in Vim.  This will avoid
        unexpected effects.
        Setting this option is useful when using Vim in a terminal, where Vim
        cannot distinguish between typed text and pasted text.  In the GUI, Vim
        knows about pasting and will mostly do the right thing without 'paste'
        being set.  The same is true for a terminal where Vim handles the
        mouse clicks itself.

使用切换粘贴模式pastetoggle

set pastetoggle=<F3>
于 2013-05-26T09:51:29.713 回答