修复Debian中的vim奇怪行为

系统 Linux
我一直在想,为什么我服务器上 vim 为什么在鼠标方面表现得如此愚蠢:不能像平时那样跳转、复制、粘贴。尽管在 /etc/vim/vimrc.local 中已经设置了。最后我终于知道为什么了,多谢 bug #864074 并且修复了它。

https://s1.51cto.com/oss/201801/24/98e510be5d2098ab91f2b88a1a32ab20.jpeg

我一直在想,为什么我服务器上 vim 为什么在鼠标方面表现得如此愚蠢:不能像平时那样跳转、复制、粘贴。尽管在 /etc/vim/vimrc.local 中已经设置了。

  1. set mouse=

***我终于知道为什么了,多谢 bug #864074 并且修复了它。

原因是,当没有 ~/.vimrc 的时候,vim 在 vimrc.local 之后加载 defaults.vim,从而覆盖了几个设置。

/etc/vim/vimrc 中有一个注释(虽然我没有看到)解释了这一点:

  1. " Vim will load $VIMRUNTIME/defaults.vim if the user does not have a vimrc.
  2. " This happens after /etc/vim/vimrc(.local) are loaded, so it will override
  3. " any settings in these files.
  4. " If you don't want that to happen, uncomment the below line to prevent
  5. " defaults.vim from being loaded.
  6. " let g:skip_defaults_vim = 1

我同意这是在正常安装 vim 后设置 vim 的好方法,但 Debian 包可以做得更好。在错误报告中清楚地说明了这个问题:如果没有 ~/.vimrc/etc/vim/vimrc.local 中的设置被覆盖。

这在Debian中是违反直觉的 - 而且我也不知道其他包中是否采用类似的方法。

由于 defaults.vim 中的设置非常合理,所以我希望使用它,但只修改了一些我不同意的项目,比如鼠标。***,我在 /etc/vim/vimrc.local 中做了以下操作:

  1. if filereadable("/usr/share/vim/vim80/defaults.vim")
  2. source /usr/share/vim/vim80/defaults.vim
  3. endif
  4. " now set the line that the defaults file is not reloaded afterwards!
  5. let g:skip_defaults_vim = 1
  6.  
  7. " turn of mouse
  8. set mouse=
  9. " other override settings go here

可能有更好的方式来获得一个不依赖于 vim 版本的通用加载语句, 但现在我对此很满意。 

责任编辑:庞桂玉 来源: Linux中国
相关推荐

2022-03-31 11:46:00

Go传输编码标准库

2015-09-16 16:51:21

2020-09-09 07:55:51

TS开源符号

2021-02-02 11:02:20

React任务饥饿行为优先级任务

2010-05-06 15:35:14

Unix操作系统

2023-08-14 09:59:31

Debian操作系统

2021-02-05 09:18:33

VS CodeVim操作

2012-11-23 16:46:12

LinuxVim

2009-06-08 20:05:14

Eclipse deb

2021-02-24 15:20:43

Windows 10Python命令

2009-11-23 09:34:05

WPF本质

2019-10-24 12:13:59

Android APP后台动画

2022-08-27 14:14:06

Spring事务开发

2020-03-22 11:20:16

Vue开发前端

2022-08-07 21:17:27

微软Windows 11

2013-04-17 10:34:55

.NET大对象堆

2015-08-11 08:51:40

游戏死亡

2018-03-05 19:20:49

LinuxWordPressHTTP

2009-03-16 09:16:13

行为扩展WCF.NET

2023-03-14 07:23:48

ReactJSX语法
点赞
收藏

51CTO技术栈公众号