cpo&vim是一种特殊的语法吗?


14

在脚本中,习惯执行以下操作:

let s:save_cpo = &cpo
set cpo&vim

... script ...

let &cpo = s:save_cpo

确保脚本的不兼容模式。

是:

set cpo&vim

某种特殊的语法,例如foo & bar?还是更像是命令,触发行或其他?

Answers:


14

是的,将选项重置为Vim默认值是一种特殊的语法。来自:help :set-&vim

:se[t] {option}&        Reset option to its default value.  May depend on the
                        current value of 'compatible'. {not in Vi}
:se[t] {option}&vi      Reset option to its Vi default value. {not in Vi}
:se[t] {option}&vim     Reset option to its Vim default value. {not in Vi}

:se[t] all&             Set all options, except terminal options, to their
                        default value.  The values of 'term', 'lines' and
                        'columns' are not changed. {not in Vi}

我是通过输入:help &vim(也转到:help :set-&vim)来找到它的:-)


4
谢谢,我不好。我一直在看cpo,vimdoc.sourceforge.net
htmldoc / usr_41.html#

2

cpo均值compatible option&均值选项变量,因此&cpo表示兼容选项的值。

set cpo&vim是一种特殊的语法,它告诉vim重置cpo默认为的选项aABceFs

请参阅中的文档 :h cpo

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.