是否可以直接从Vim复制到剪贴板?yy只把东西复制到Vim的内部缓冲区。我想复制到操作系统的剪贴板。在Vim中有这样的命令吗?或者你只能在Vim中提取东西?
当前回答
到目前为止,我在MacOsX上使用键盘快捷键已经为此挣扎了几个月。 我知道问题不是关于使用键盘短裤。但这可能会对有同样担忧的人有所帮助。
我发现如果你不勾选:
View ->允许鼠标报告
从终端菜单,您将能够复制到剪贴板使用
Command + c
一次。
其他回答
在我的情况下,使用鼠标和右键复制的帮助进行选择。
我不希望包括行号,所以我:在复制之前设置nonnumber。
在vimrc文件中,可以指定自动使用系统剪贴板进行复制和粘贴。
macOS和Windows设置:
set clipboard=unnamed
Linux set (vim 7.3.74+):
set clipboard=unnamedplus
注意:您可能需要使用最新版本的Vim才能工作。
http://vim.wikia.com/wiki/Accessing_the_system_clipboard
以上这些在我的windows笔记本电脑上都不起作用。
Ctrl+C可以用于复制。但我需要 Shift+插入到粘贴!
(一个很好的理由,总是有一个笔记本电脑,可以随时插入,而不需要按第二个键)
In case you don't want to use any graphical interface for vim and you prefer to just stick with terminal emulator there may be a much simpler approach to this problem. Instead of using yank or anything like this, first take a look at documentation of terminal you use. I've been struggling with the same issue (trying to use +clipboard and xclip and so on) and in the end it turned out that in my terminal emulator it's enough to just press shift and select any text you want to copy. That's it. Quite simple and no need for messing with configuration. (I use urxvt by the way).
*寄存器将执行此操作。在Windows中,+和*是等价的。在unix中,+和*之间有细微的区别:
在Windows下,*和+寄存器 是等价的。对于X11系统, 不过,它们有所不同。对于X11系统, *是选区,+是剪切缓冲区(如剪贴板)。 http://vim.wikia.com/wiki/Accessing_the_system_clipboard
*可能是您大多数时候想要的,所以我使用*,因为它在两种环境中都能正常工作。
在Linux发行版中,你必须先安装vim-gtk(又名gvim)才能获得剪贴板功能。这是因为非gtk vim通常在编译时没有X11支持。这是为了允许它只在控制台机器(通常是服务器)上运行。
对于那些在拉取或放入时如何使用寄存器感到困惑的人,你只需写上“然后是寄存器的名称”。因此,要将内容复制到剪贴板寄存器,您只需输入“*y”,然后输入“*p”(来源:Kyle Mathews)