如何将vi中的代码复制到剪贴板
我知道如何在VI中复制。但我未能将其复制到其他应用程序中。这意味着我未能将它们复制到剪贴板中。 我该怎么做?
PS为了更精益。我还想问如何将剪贴板中的内容复制到vi。
编辑: 我正在使用 MacO。运行 Vim。
看来 *yy 在这里不起作用。还有其他办法吗?
I know how to copy in VI. but I failed to copy it into other application. That means I failed copy those into clipboard.
How can I do this?
P.S. In order to lean more. I also want to ask how to copy content from clipboard to vi.
Edited:
I am using MacOs. running Vim.
It seems *yy doesn't work here. Any other ways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要使用剪贴板寄存器,即
*
,因此要将一行文本复制到剪贴板中:从剪贴板粘贴一行文本:
You need to use the clipboard register, which is
*
, so to copy a line of text into clipboard:To paste a line of text from the clipboard:
仅当您的 vim 支持 xterm_clipboard 时,
"+y
或"*y
才有效。 Xterm 是 X11 的终端模拟器。尝试vim --version
看看是否支持。如果您看到+xterm_clipboard
,它应该可以工作,如果您看到-xterm_clipboard
,它就不会。现在有许多 Linux 版本在其存储库中仍然禁用 xterm_clipboard 支持。通过剪贴板进行拉动是不可能的。请注意,您仍然可以使用老式的 Unix 风格的拉取/粘贴,即选择要拉取的文本,然后在要粘贴的位置单击鼠标中键。这应该始终有效,并且是 vim 中拉取/粘贴的首选方式。确保处于插入模式并输入set Paste
(如果它搞乱了缩进)。设置 nopaste
以离开粘贴模式。要使用 xterm_clipboard 获取 vim,只需下载源代码,创建
./configure --with-x
,然后创建make
。现在 vim 应该支持 xterm_clipboard 并且从剪贴板中拖拽和粘贴也应该可以完美地工作。"+y
or"*y
works only if your vim supports the xterm_clipboard. Xterm is a terminal emulator for X11. Tryvim --version
to see if it is supported. If you see+xterm_clipboard
it should work, if you see-xterm_clipboard
it won't. Now there are many Linux flavours which still have the xterm_clipboard support deactivated in their repositories. Yanking via clipboard is then impossible. Note that you still have the good old unix style of yank/paste, namely select the text you'd like to yank and middle-click on the mouse where you want to paste. This should work always and is the preferred style of yank/paste in vim. Be sure to be in insert mode and typeset paste
if it screws up the indentation.set nopaste
to leave paste mode.To get vim with xterm_clipboard, simply download the source, make a
./configure --with-x
and then amake
. Now vim should support xterm_clipboard and yanking and pasting should work flawlessly also from the clipboard."
会将其放入+
寄存器中。甚至比您想知道的还要多:
http://vim.wikia.com/wiki/Accessing_the_system_clipboard
The
"
will put it into the+
register.For even more than you wanted to know:
http://vim.wikia.com/wiki/Accessing_the_system_clipboard
vi 的复制是在 vi 自己的内部剪贴板中完成的,因为它源自 unix 命令行,而 windows 风格的剪贴板不存在。后来出现了命令行的鼠标指针,这意味着您可以使用它作为更像 Windows 样式进行复制,但如果您想从 vi 复制到 Windows 剪贴板,则需要使用 *yy 和 *p,而不是 yy 和 p vi 中的内部剪贴板(这也是为什么拉动和粘贴不会影响您的 Windows 剪贴板)
The copy of vi is done within vi's own internal clipboard, as its descended from the unix command line where the windows style clipboard didnt exist. Later came the mouse pointer for command line which meant you could copy using that as a more like windows style, but if you want to copy from vi to windows clipboard, you need to use *yy and *p, not yy and p which are the internal clipboard within vi (which is also why yanking and pasting dont effect your windows clipboard)