Chinaunix首页 | 论坛 | 博客
  • 博客访问: 348552
  • 博文数量: 161
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 345
  • 用 户 组: 普通用户
  • 注册时间: 2013-12-13 11:04
文章分类

全部博文(161)

文章存档

2015年(15)

2014年(144)

2013年(2)

我的朋友

分类: 网络与安全

2014-12-23 17:17:00

新修改了~/.vimrc 文件之后, 发现鼠标右健无法复制文本。
发现在配置文件(~/.vimrc)中发现,有这样一段话:
 11 " In many terminal emulators the mouse works just 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 mouse for
modeless selection.  This doesn't move the text cursor.

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

其中涉及的背景知识是:

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

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

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

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