How to put modelines in a CSS file

23 views
Skip to first unread message

Steve Litt

unread,
Nov 30, 2024, 9:48:15 PM11/30/24
to vim...@googlegroups.com
Hi all,

I needed to put vim:ts=3:sw=3:expandtab:nu:ic: into my CSS file. When
I tried:

/* vim:ts=3:sw=3:expandtab:nu:ic: */

The preceding gave me a "Unknown option: */" error when I reread the
file. So then I tried:

// vim:ts=3:sw=3:expandtab:nu:ic:

The preceding was OK with Vim, but gave me a CSS parse error.

So I figured "OK, I'll play your silly game, went back to /* and */,
but put the */ on the following line:

/* vim:ts=3:sw=3:expandtab:nu:ic:
*/

The preceding passed CSS validation, errorlessly survived a Vim reread,
and was honored by Vim. You guys probably knew this already, but for
anybody who didn't, this is what you do when your comments require a
closing tag: Just end one line with the modeline and put everything
else on the next line.

SteveT

Steve Litt
http://444domains.com

Tim Chase

unread,
Nov 30, 2024, 10:01:42 PM11/30/24
to vim...@googlegroups.com
On 2024-11-30 21:48, Steve Litt wrote:
> I needed to put vim:ts=3:sw=3:expandtab:nu:ic: into my CSS file. When
> I tried:
>
> /* vim:ts=3:sw=3:expandtab:nu:ic: */
>
> The preceding gave me a "Unknown option: */" error when I reread the
> file.
[snip]
> put the */ on the following line:
>
> /* vim:ts=3:sw=3:expandtab:nu:ic:
> */

Reading over `:help modeline`, I think your commented-version needs to
omit the extra in-modeline colons (just keeping the first/last):

/* vim: ts=3 sw=3 et nu ic: */

worked from my testing, allowing everything in one line, and also not
getting the vim error.

-tim





Steve Litt

unread,
Nov 30, 2024, 11:58:21 PM11/30/24
to vim...@googlegroups.com
Tim Chase said on Sat, 30 Nov 2024 21:01:33 -0600
Thanks Tim!
Reply all
Reply to author
Forward
0 new messages