选择自动放入X11剪贴板 - VIM

时间:2011-11-03 15:19:25

标签: vim

在我以前的Linux安装中,当我在可视模式下选择一些文本时(没有鼠标!),它会自动将它放在我的X11剪贴板中。然后我可以使用鼠标中键自然地将此文本粘贴到其他任何地方。

使用我的新Linux安装,这不再起作用了(只是在可视模式下选择文本不再将它放在X11剪贴板中)。

我怎样才能获得这个好看的功能?

(我对"*y"+y解决方案不感兴趣,顺便说一句,这些解决方案对我的系统无效。)

提前致谢!

5 个答案:

答案 0 :(得分:7)

视觉选择(v,V或CTRL-V)可以自动复制到 X11选择(*缓冲区)。

在非gui模式下,剪贴板选项控制它(仅当支持时才支持) 键入vim --version时会出现+ xterm_clipboard。在gui模式 guioptions控制它。

这使得所有可视模式选择自动转到X11主要版本 选择:

set clipboard+=autoselect
set guioptions+=a

这将其关闭:

set clipboard-=autoselect
set guioptions-=a

在vim中看到:

help 'clipboard'

(需要单引号)

答案 1 :(得分:3)

使用:

set guioptions+=a

这适用于GUI(Gvim)。参考文献位于:help guioptions_a

                        *guioptions_a* *'go-a'*
  'a'   Autoselect:  If present, then whenever VISUAL mode is started,
    or the Visual area extended, Vim tries to become the owner of
    the windowing system's global selection.  This means that the
    Visually highlighted text is available for pasting into other
    applications as well as into Vim itself.  When the Visual mode
    ends, possibly due to an operation on the text, or when an
    application wants to paste the selection, the highlighted text
    is automatically yanked into the "* selection register.
    Thus the selection is still available for pasting into other
    applications after the VISUAL mode has ended.
        If not present, then Vim won't become the owner of the
    windowing system's global selection unless explicitly told to
    by a yank or delete operation for the "* register.
    The same applies to the modeless selection.

答案 2 :(得分:1)

在Arch和Gentoo Linux上的gnome-terminal中使用Vim时,这个功能正常运行。

在Konsole中使用Vim时,这不起作用。

使用gvim -v将启动set guioptions+=a 工作的终端版GVim:   在该Vim中选择的任何文本都会自动复制到Linux的选择缓冲区。

要从选择缓冲区粘贴文本,请按鼠标中键

答案 3 :(得分:0)

在我的Debian上,我在安装vim-gnome软件包后得到了它。

来自pkg-vim-maintainers邮件列表的评论指示安装vim-gtk,vim-gnome或vim-lesstif。

答案 4 :(得分:0)

通过新安装的Kali,我通过为gnome-terminal安装vim-gtk软件包解决了上述问题。 vim-gtk软件包将“ -xterm_clipboard”更改为“ + xterm_clipboard”,从而解决了该问题。在vim中选择文本后,该文本将自动复制到系统剪贴板。

相关问题