.vimrc使能鼠标后,vim鼠标右键不能复制

转自:http://blog.sina.com.cn/s/blog_622d95080100ny94.html


在~/.vimrc中加入 set mouse=a 后,vim鼠标右键变得不能复制了,解决办法如下:

按住 shift 键,然后选择,此时表示由 X 处理该选择,copy 选项就 enable 了。如果放掉shift键,则由 vim处理该选择。


原文:

新修改了~/.vimrc 文件之后, 发现鼠标右健无法复制文本。

发现在配置文件(~/.vimrc)中发现,有这样一段话:
 
11 " In many terminal emulators the mouse worksjust fine, thus enable it.
  12 if has('mouse')
  13   set mouse=a
  14 endif

在vim帮助文件中发现了如下的解释:
The mouse can be enabled for different modes:
                                        Normal mode
                                        Visual mode
                                        Insert mode
                                        Command-line mode
                                        all previous modes when editing a help file
                                        all previous modes
                                        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 mousefor
modeless selection.  This doesn't move the textcursor.

所以配置文件中的set mouse=a启动了所有模式, vim接管了鼠标的控制。

其中涉及的背景知识是:

鼠标事件有两种处理方式,程序处理和 X 处理。

如果 X 负责处理,则是左键选择,中间粘贴。

要让 vim 中由 X 负责处理,有两个方法:

1. 按住 shift 键,然后选择,此时由 X 处理该选择,copy 选项就 enable 了。如果放掉shift键,则由 vim处理该选择。
2. 在 .vimrc 中设置 set mouse= (就是说清空),此时vim永远不再干涉鼠标选择,永远把处理权交给X,这个时候鼠标就处于无模式编辑状态, 当然也能用鼠标来切换vim里面的tab窗口了,vim中的编辑光标也不会跟随鼠标了。

  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值