To set the filetype to xml for a file file.xml, append
<!-- vim:filetype=xml -->to file.xml. With modeline set, :edit file.xml gives the error message
E518: Unknown option: -->
Vim should infer by the commentstring option that
commentstring=<!--%s-->
and therefore that --> is the closing comment marker, and not a modeline setting.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
Well:
Vim should infer by the commentstring option that
:h commentstring
Currently only used to add markers for folding, see |fold-marker|.
Therefore no, it doesn't.
And :h modeline
There are two forms of modelines. The first form:
[text]{white}{vi:|vim:|ex:}[white]{options}
(...)
Examples:
vi:noai:sw=3 ts=6 ~
vim: tw=77 ~
The second form (this is compatible with some versions of Vi):
[text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text]
(...)
Examples:
/* vim: set ai tw=75: */ ~
/* Vim: set ai tw=75: */
And you have two options, either
<!-- vim: ft=xml
-->
And
<!-- vi: set ft=xml: -->
Which is more compatible anyway.
Also, this probably should be in vim_users mailing list or vi.stackexhange.com. Not an issue on github (and be closed here).
The 'commentstring' option can only be set after detecting the filetype, thus it can't be used for the modeline.
Closed #1648.
For example, the markdown comment [//]: # ( vim: spell:spelllang=en: ) still produces the error message:
Error detected while processing modelines: line 309: E518: Unknown option: )
I am sorry, the set makes the difference. I thought it was about the trailing :. It's fine.