vim 鼠标右键无法复制(转)

新修改了~/.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中的编辑光标也不会跟随鼠标了。

======================

新安装了vim,把配置拷贝到/etc/vim/vimrc,结果发现右键中的拷贝变成灰显了,不要用了,很不方便,郁闷。

网上说是因为set mouse=a,可/etc/vim/vimrc中并没有关于mouse的设置。

后来发现还有一个配置文件~/.vimrc,这里面有set mouse=a。以后还是直接把配置文件拷贝到~/.vimrc中,免得麻烦。

cp vimrc  ~/.vimrc
mkdir -p  ~/.vim/colors
cp molokai.vim  ~/.vim/colors/

原文地址:https://www.cnblogs.com/kuainiao/p/2836023.html