解決在Vim中鼠標右鍵不能粘貼


最近維護一台服務器,使用putty登錄后,用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+shift+c不能用了,鼠標右鍵復制選項也是灰的。
到網上,搜了一下,發現是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鍵復制,然后點擊要粘貼的地方使用鼠標中鍵粘貼!!!
支持誇文件粘貼,比使用命令方便多了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM