Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
vim e518:未知选项:_Vim - Fatal编程技术网

vim e518:未知选项:

vim e518:未知选项:,vim,Vim,我在unix系统上有一个文本文件。以下文本文件内容造成了问题: good: ok line vi: bad line ok: ok line 如果删除我的~/.vimrc,错误就会消失。但奇怪的是,即使有一个空的~/.vimrc文件,也会出现错误 我知道这是因为该行以vi:开头,所以创建了错误,但我不明白为什么或如何修复此错误。您可以使用关闭modeline处理 :set nomodeline 有关详细信息,请参见:help modeline。在:help auto setting下,您可以找

我在unix系统上有一个文本文件。以下文本文件内容造成了问题:

good: ok line vi: bad line ok: ok line 如果删除我的
~/.vimrc
,错误就会消失。但奇怪的是,即使有一个空的
~/.vimrc
文件,也会出现错误


我知道这是因为该行以
vi:
开头,所以创建了错误,但我不明白为什么或如何修复此错误。

您可以使用关闭modeline处理

:set nomodeline

有关详细信息,请参见
:help modeline

:help auto setting
下,您可以找到以下段落:

3. If you start editing a new file, and the 'modeline' option is on, a
   number of lines at the beginning and end of the file are checked for
   modelines.  This is explained here. 

There are two forms of modelines.  The first form:
    [text]{white}{vi:|vim:|ex:}[white]{options}

[text]      any text or empty
{white}     at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:}  the string "vi:", "vim:" or "ex:"
[white]     optional white space
{options}   a list of option settings, separated with white space or ':',
        where each part between ':' is the argument for a ":set"
        command (can be empty)

Example:
   vi:noai:sw=3 ts=6 ~

The second form (this is compatible with some versions of Vi):

    [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]

[text]      any text or empty
{white}     at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:}  the string "vi:", "vim:" or "ex:"
[white]     optional white space
se[t]       the string "set " or "se " (note the space)
{options}   a list of options, separated with white space, which is the
        argument for a ":set" command
:       a colon
[text]      any text or empty

Example:
   /* vim: set ai tw=75: */ ~

The white space before {vi:|vim:|ex:} is required.  This minimizes the chance
that a normal word like "lex:" is caught.  There is one exception: "vi:" and
"vim:" can also be at the start of the line (for compatibility with version
3.0).  Using "ex:" at the start of the line will be ignored (this could be
short for "example:").
3。如果开始编辑新文件,并且“modeline”选项处于启用状态,则
检查文件开头和结尾处的行数
模型线。这里解释了这一点。
模型线有两种形式。第一种形式:
[文本]{white}{vi:| vim:| ex:}[白色]{options}
[文本]任何文本或空文本
{white}至少一个空白字符(或)
{vi:| vim:| ex:}字符串“vi:”、“vim:”或“ex:”
[白色]可选的空白
{options}选项设置列表,用空格或“:”分隔,
其中,“:”之间的每个部分都是“:set”的参数
命令(可以为空)
例子:
vi:noai:sw=3 ts=6~
第二种形式(与Vi的某些版本兼容):
[text]{white}{vi:| vim:| ex:}[white]se[t]{options}:[text]
[文本]任何文本或空文本
{white}至少一个空白字符(或)
{vi:| vim:| ex:}字符串“vi:”、“vim:”或“ex:”
[白色]可选的空白
se[t]字符串“set”或“se”(注意空格)
{options}选项列表,用空格分隔,它是
“:set”命令的参数
:冒号
[文本]任何文本或空文本
例子:
/*vim:设置ai tw=75://~
{vi:| vim:|ex:}之前的空白是必需的。这使机会最小化
一个像“莱克斯:”这样的普通词被抓住了。有一个例外:“vi:”和
“vim:”也可以位于行的开头(与版本兼容
3.0).  在行首使用“ex:”将被忽略(这可能是
“示例:”的缩写。
因此,在~/.vimrc中,可能有一个
集合nomodeline

行读取
vi:bad line
尝试设置无法设置的选项
bad
line
,因此出现错误


EDIT:正如jamessan的回答(+1)所指出的,
modeline
选项是通过设置nocompatible来设置的,只要存在
~/.vimrc
vi:bad line
行的格式是Vim识别为a的,如错误消息中所述。模型线允许在文件中设置选项

当您没有
~/.vimrc
时,它不会触发的原因是Vim要求您在默认情况下为模型线设置
'nocompatible',因为它是Vim特有的功能。然而,
~/.vimrc
的存在足以让Vim从vi兼容模式切换到nocompatible模式,这将导致设置
'modeline'
选项


为了便于将来参考,您可以通过
:help topic
在Vim中轻松找到帮助主题。在本例中,
:help modeline
将为您提供一些主题,让您了解如何解释此功能以及如何控制它。

非常感谢您的解释。奇怪的是,我的行只是1000+行中的696行(这是一个大的/etc/group文件)。但它解决了我的问题。谢谢你。我将此标记为已接受答案,因为它解释了发生的情况和原因(vimrc的存在)。因此vim将最后的
n
行理解为
modelines
(即vim设置)因此,最好将代码的最后一行保留为空行或实际的vim modelines,以避免此错误。
3. If you start editing a new file, and the 'modeline' option is on, a
   number of lines at the beginning and end of the file are checked for
   modelines.  This is explained here. 

There are two forms of modelines.  The first form:
    [text]{white}{vi:|vim:|ex:}[white]{options}

[text]      any text or empty
{white}     at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:}  the string "vi:", "vim:" or "ex:"
[white]     optional white space
{options}   a list of option settings, separated with white space or ':',
        where each part between ':' is the argument for a ":set"
        command (can be empty)

Example:
   vi:noai:sw=3 ts=6 ~

The second form (this is compatible with some versions of Vi):

    [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]

[text]      any text or empty
{white}     at least one blank character (<Space> or <Tab>)
{vi:|vim:|ex:}  the string "vi:", "vim:" or "ex:"
[white]     optional white space
se[t]       the string "set " or "se " (note the space)
{options}   a list of options, separated with white space, which is the
        argument for a ":set" command
:       a colon
[text]      any text or empty

Example:
   /* vim: set ai tw=75: */ ~

The white space before {vi:|vim:|ex:} is required.  This minimizes the chance
that a normal word like "lex:" is caught.  There is one exception: "vi:" and
"vim:" can also be at the start of the line (for compatibility with version
3.0).  Using "ex:" at the start of the line will be ignored (this could be
short for "example:").