You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

为何Vim启动与执行:source /etc/vimrc时/etc/vimrc设置生效不同?

Vim插件禁用失效问题排查与解决

问题现象

  • 为禁用PHP文件编辑时的插件行为,在/etc/vimrc.custom中添加filetype plugin off,并在默认/etc/vimrc末尾加入source /etc/vimrc.custom
  • 执行:source /etc/vimrc时,:verbose filetype返回正确状态:filetype detection:ON plugin:OFF indent:ON
  • 直接启动Vim打开文件时,插件仍处于开启状态,:verbose filetype返回:filetype detection:ON plugin:ON indent:ON
  • 直接执行:source /etc/vimrc.custom可正常禁用插件

排查过程

  • ~/.vimrc的存在(即使为空)会改变脚本加载顺序,通过:scriptnames可观察到差异:无~/.vimrc时,/usr/share/vim/vim82/indent.php会加载并覆盖formatoptions;有~/.vimrc时该文件不会加载
  • 自Vim 8.0起,若不存在~/.vimrc,系统会加载$VIMRUNTIME/defaults.vim,且该文件在/etc/vimrc之后加载,因此会覆盖/etc/vimrc及其引用脚本的自定义设置

解决方法

在/etc/vimrc或你使用的vimrc配置文件中添加以下配置:

let skip_defaults_vim = 1

内容的提问来源于stack exchange,提问作者Shovas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 20:02:05