1. 程式人生 > >解決在Vim中滑鼠右鍵不能貼上

解決在Vim中滑鼠右鍵不能貼上

最近維護一臺伺服器,使用xshell登入後,用vim時,滑鼠右鍵不能貼上而是進入了visual模式。網上查詢一番找到了解決方法: 方法一:在普通模式下鍵入“ :set mouse-=a”(不包括引號) 方法二:編輯 ~/.vimrc 檔案,加入如下程式碼: if has('mouse') set mouse-=a endif 方法一每次開啟vim時都需要設定一次。方法二改了配置檔案後,問題就解決了。 參考:www.varesano.net/blog/fabio/disable%20vim%20automatic%20visual%20mode%20using%20mouse

(轉)

之前,為了解決一個語法加亮的問題更改了vimrc,之後,突然發現滑鼠可以使用了,點到那裡游標就定位到 
那裡,但是,隨後發現,ctrl+insert不能用了,滑鼠右鍵複製選項也是灰的。
到網上,搜了一下,發現是set mouse=a這句話的問題
這個是用來開啟滑鼠功能的。a表示所有模式

vi的三種模式:命令模式,插入模式,可視模式.滑鼠可以啟動於各種模式中:
The mouse can be enabled for different modes:
n Normal mode
v Visual mode
i Insert mode
c Command-line mode
h all previous modes when editing a help file
a all previous modes
r for |hit-enter| and |more-prompt| prompt
Normally you would enable the mouse in all four modes with:
:set mouse=a
When the mouse is not enabled, the GUI will still use the mouse for
modeless selection. This doesn't move the text cursor.

所以配置檔案中的set mouse=a啟動了所有模式,這樣就遮蔽了滑鼠右健功能.

這裡我設定為set mouse=v在可視模式下使用滑鼠,然後搞定。

但是,這樣,其他模式就無法使用滑鼠定位了,有點不爽。莫非魚和熊掌不能兼得??

又到網上找了下,發現確實這樣,不過卻另有所獲:
無須更改set mouse=a

用滑鼠選中,按y鍵複製,然後點選要貼上的地方使用滑鼠中鍵貼上!!!
支援誇檔案貼上,比使用命令方便多了