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

sub*_*ift 5 vim

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

使用我的新Linux安装,这不再起作用(仅在可视模式下选择文本不再将其放入X11剪贴板中).

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

(我对这些"*y"+y解决方案不感兴趣,顺便说一下,这对我的系统不起作用.)

提前致谢!

小智 7

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

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

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

set clipboard+=autoselect
set guioptions+=a
Run Code Online (Sandbox Code Playgroud)

这将其关闭:

set clipboard-=autoselect
set guioptions-=a
Run Code Online (Sandbox Code Playgroud)

在vim中看到:

help 'clipboard'
Run Code Online (Sandbox Code Playgroud)

(需要单引号)


Ben*_*oit 3

使用:

set guioptions+=a
Run Code Online (Sandbox Code Playgroud)

这适用于 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.
Run Code Online (Sandbox Code Playgroud)