vim e518: unknown option:

vim

Solution

The `vi: bad line` line is in a format that Vim recognizes as a modeline, as mentioned in the error message. Modelines allow one to set options within a file.

The reason it isn't triggered when you don't have a `~/.vimrc` is because Vim requires you have `'nocompatible'` set for modelines to be enabled by default, since it is a Vim-specific feature. The existence of `~/.vimrc` is enough for Vim to switch from vi-compatible mode to nocompatible, though, which will result in the `'modeline'` option also being set.

For future reference, you can easily find help topics in Vim via `:help topic<Tab>`. In this case, `:help modeline<Tab>` would have given you a few topics to look into which explain this feature and how to control it.

Problem

I have a text file on a unix system. The following text file content creates the problem: ``` good: ok line vi: bad line ok: ok line ``` So if I run: `vim test.txt`, I get the following error: ``` "test.txt" 3L, 39C Error detected while processing modelines: line 2: E518: Unknown option: bad Press ENTER or type command to continue ``` If I delete my `~/.vimrc`, the error disappears. But what is weird is that, even with an empty `~/.vimrc` file, the error appears. I understand that it's because the line starts with `vi:` that the error is created, but I don't understand why or how to fix this.

Original source