加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

在.vimrc中,“set nocompatible”完全无用?

发布时间:2020-12-15 16:39:57 所属栏目:安全 来源:网络整理
导读:this epic question中的几个用户将.vimrc中的以下内容: " Necesary for lots of cool vim thingsset nocompatible 但是真的有必要吗?从文档: 'compatible' 'cp' boolean (default on,off when a |vimrc| or |gvimrc| file is found) 如果设置nocompatible
this epic question中的几个用户将.vimrc中的以下内容:
" Necesary for lots of cool vim things
set nocompatible

但是真的有必要吗?从文档:

'compatible' 'cp'
    boolean (default on,off when a |vimrc| or |gvimrc| file is found)

如果设置nocompatible进入一个.vimrc,这意味着.vimrc文件存在,似乎使它无意义。

如果是系统范围的vimrc,则此选项不会关闭。因此,如果您要更改系统范围的vimrc,并且您需要它,您需要设置它。

从文档部分*compatible-default*(强调我):

When Vim starts,the ‘compatible’
option is on. This will be used when
Vim starts its initializations. But
as soon as a user vimrc file is found,
or a vimrc file in the current
directory
,or the “VIMINIT”
environment variable is set,it will
be set to ‘nocompatible’.

另一个区别是显式设置“不兼容”的操作,使用-C flag调用vim。

在任何其他情况下,是的,在你的vimrc中设置’nocompatible’是一个noop。

最后,我认为这只是一个“更安全比对不起”的问题。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读