在 .vimrc 中,`set nocompatible` 是完全没用的吗? [英] In a .vimrc, is `set nocompatible` completely useless?

查看:55
本文介绍了在 .vimrc 中,`set nocompatible` 是完全没用的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个史诗般的问题中的几个用户在中输入了以下内容.vimrc:

" Necesary for lots of cool vim things
set nocompatible

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

But is it really necessary? From the docs:

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

如果 set nocompatible.vimrc 中,这意味着 .vimrc 文件存在,看起来毫无意义.>

If set nocompatible is going in a .vimrc, that means that a .vimrc file exists, seemingly making it pointless.

推荐答案

如果是系统范围的vimrc,这个选项不会关闭.因此,如果您要更改系统范围的 vimrc 并且想要它,则需要对其进行设置.

If it is the system-wide vimrc, this option won't be off. So, if you're changing the system-wide vimrc and you want it, you need to set it.

来自文档部分*compatible-default*(重点是我的):

From the documentation section *compatible-default* (emphasis mine):

当 Vim 启动时,'兼容'选项打开.这将在Vim 开始初始化.但一旦找到用户 vimrc 文件,或 当前目录中的 vimrc 文件目录,或VIMINIT"设置环境变量,它将设置为不兼容".

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'.

另一个区别是显式设置nocompatible"会否决使用 -C 标志调用 vim.

Another difference is that explicitly setting 'nocompatible' overrules calling vim with the -C flag.

在任何其他情况下,是的,在您的 vimrc 中设置 'nocompatible' 是无用的.

In any other scenario, yes, setting 'nocompatible' in your vimrc is a noop.

最后,我认为这只是一个安全总比后悔好"的问题.

In the end I think it's just a matter of "better safe than sorry".

这篇关于在 .vimrc 中,`set nocompatible` 是完全没用的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆