2011-11-03 39 views
5

在我之前的Linux安裝中,當我以可視模式(不帶鼠標!)選擇一些文本時,它會自動將它放入我的X11剪貼板。然後,我可以使用鼠標中間按鈕自然地粘貼此文本。選擇自動放入X11剪貼板 - VIM

隨着我的新Linux安裝,這不再工作了(僅在可視化模式下選擇文本不會將它放在X11剪貼板了)。

我該如何獲得這個不錯的功能?

(我沒興趣到"*y"+y解決方案,它的方式並不在我的系統上運行。)

提前感謝!

+0

vim標籤的3K +追隨者怎麼樣?如果答案對你來說很簡單,爲什麼不把它寫下來呢? – subshift

+0

@Max但是什麼是Stackoverflow手冊? – DerMike

+2

如果''+ y'和'「* y'在你的系統中不起作用,你應該檢查一下你是否可以得到一個編譯好的與X11交互的Vim版本。 – Benoit

回答

3

用途:

set guioptions+=a 

這工作與圖形界面(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. 
+0

非常感謝你的回答。不幸的是它不起作用。我擔心這個問題來自我的系統,但我不明白在哪裏,因爲我的vim版本似乎是用所需的功能編譯的,正如我在原文中的評論中提到的那樣。 – subshift

0

在我的Debian上,我在安裝vim-gnome包後得到了它的工作。

來自pkg-vim-maintainers郵件列表的評論指示安裝vim-gtk,vim-gnome或vim-lesstif。

1

在Arch和Gentoo Linux上的gnome-terminal中使用Vim時,此功能正常工作。

在Konsole中使用Vim時,這不起作用。

使用gvim -v將推出的GVim的終端版本,其中set guioptions+=a工作: 到Vim內選擇任何文本會自動複製到Linux的選擇緩衝區。

要粘貼從選擇緩衝液按鼠標中鍵

6

視覺選擇(V,V,或CTRL-V)可以自動被複制到 X11選擇(*緩衝液)的文本。

在non-gui模式下,剪貼板選項控制此選項(僅當您鍵入vim --version時出現 + xterm_clipboard時才支持)。在gui模式下,guioptions控制它。

這使得所有視覺模式選擇自動轉到X11主要 選擇:

set clipboard+=autoselect 
set guioptions+=a 

此將其關閉:

set clipboard-=autoselect 
set guioptions-=a 

在Vim裏看到:

help 'clipboard' 

(需要單引號)