如何阻止vim在从剪贴板粘贴时插入注释字符?
当我将如下所示的行粘贴到 Vim 时,
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
Vim 会自动将 "
注释字符添加到所有行中。我如何摆脱它并使其按原样粘贴?
What I'm getting after the paste in Vim:
66 " OmniCppComplete
67 " let OmniCpp_NamespaceSearch = 1
When I paste lines, like the ones below, to Vim,
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
Vim automagically adds the "
comment character to all lines. How do I get rid of this and have it paste as it is?
What I'm getting after the paste in Vim:
66 " OmniCppComplete
67 " let OmniCpp_NamespaceSearch = 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
两个主要选项:
"+p
"
表示“使用以下寄存器”;+
指剪贴板,p
表示放置!如果您使用的是在 Linux 中单击鼠标中键选择粘贴,请使用
*
而不是+
来引用它,:set Paste
。使用:set nopaste
退出插入模式后将其关闭。Two main options:
"+p
"
means "use the following register";+
refers to the clipboard, andp
for put!Should you be using the middle click selection paste in Linux, use
*
instead of+
to refer to it.:set paste
. Turn it off once you leave insert mode with:set nopaste
.在 Vim 中进入
:set Paste
模式。然后按 Ctrl + Shift + V。它会起作用的。
不要通过编辑和粘贴来粘贴。这是行不通的。
In Vim go to the mode
:set paste
. Then press Ctrl + Shift + V.It would work.
Don't paste by going to edit and paste. It won't work.
到目前为止,每个人都没有抓住重点。当您开始新行时(无论是粘贴还是键入),Vim 会自动插入注释字段。
您至少使用 r 和 o 选项设置了格式选项。要查看您的设置,请键入
要删除这些选项,请键入
粘贴,然后就会按照您期望的方式工作。
键入
以查看格式选项中的字母各自的含义。
Everybody so far is missing the point. Vim is automatically inserting the comment field when you start a new line (whether it is from a paste or from your typing).
You have formatoptions set with at least the r and maybe the o option. To see your settings, type
To remove those options, type
Paste will then work the way you expect.
Type
to see what the letters in formatoptions each mean.
当您在 UI 中使用 Vim 时,请转到菜单终端 → 重置和清除。然后尝试粘贴您拥有的代码。
它将按原样粘贴。
When you are working on Vim in the UI, go to menu Terminal → Reset and clear. Then try to paste the code that you have.
It would get pasted as it is.