Russell Bateman wrote:
I found that I got an error with

   <!-- vim: ts=2 sw=2: -->

Error detected while processing modelines:
line 789 (the last line of my file, but I tried it also on lines 1 and 2 (after the <html> tag) with the same result)
E518: Unknown option: -->
Hit ENTER or type command to continue

Instead, I had to put this:

   <!--
   vim: ts=2 sw=2:
   -->

I wonder why.
[...]

As Christian Robinson mentioned earlier in this thread, there are two kinds of Vim modelines. The first kind is like the one above; you can have anything (plus a space) before "vim:" but you can't have anything (other than spaces and tabs) after the last option setting, until the end-of-line. Thus you could use

        <!--
        vim: ts=2 sw=2
        -->

or

        <!-- vim: ts=2 sw=2
        -->

The second kind of modeline consists of a ":set" statement between colons, preceded by anything plus whitespace plus "vim" and followed by anything on the same line. Thus you could use

        <!-- vim: set ts=2 sw=2 :-->

_with_ the word "set" and with a colon before the end-of-comment. (This also implies that it would be a Bad_Thing™, at any future time, to patch Vim so as to introduce an option named 'set'.)


BTW, IMHO that modeline has a more "logical" place in the <HEAD> section, next to the <META> tags if any, but that's just my preference, it's not cast in bronze for everybody everywhere.


See ":help modeline".
Best regards,
Tony.

Reply via email to