您的位置:首页 > 其它

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

2012-05-03 15:37 561 查看
转自: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:

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 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中的编辑光标也不会跟随鼠标了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: