Vim syntax highlighting file for q3 config files

Ben Millwood thebenmachine at googlemail.com
Sat May 3 15:37:54 EDT 2008


Hi, I was editing some .cfg files in Vim and noticed that it tries to
highlight them according to a series of rules that don't at all apply to
q3's config files, except for comments. Especially annoying was the tendency
to mess up cvars whose value strings contained an equals sign, and the
treating of ; as a comment in vstr strings. I could turn off syntax
highlighting altogether, but that was less than satisfactory.
Not content with any of these options, I decided to create an altogether new
syntax highlighting file exclusively for quake3 config files.
It does the following:
1) Colours comments (// to end of line) according to your Comment rule
(usually some shade of blue)
2) Colours common cfg commands (set[asu], bind, exec, vstr, and map)
according to your Statement rule (usually yellow)
3) Highlights TODO and FIXME in comments and strings according to your Todo
rule (yellow background, black text)
4) In strings, attempts to convert colour codes ^[0-8] until the next code
or until a " to their appropriate colour

It's the first such file I've ever written, and as yet I've found no way to
have vim differentiate between the cfgs it expects and quake3 config files,
so you pretty much have to choose one or the other (or, at the top of your
config files place a line that reads "// vim: set filetype=q3cfg :" and
configure for that filetype in your .vimrc). I also have no idea whether the
colours that correlate on my screen also correlate on yours, so I apologise
in advance if I cause you to claw out your own eyes in horror. The commands
I chose to highlight are a bit arbitrary (mostly what I just stumbled upon
in server.cfg and autoexec.cfg) and, as I comment in the file, might be
generalisable. Another thing lacking is a nice highlighting of strings (I
just don't know what to do with them) and non-quoted values (I don't even
know how to match them).

I'm sure this mailing list is composed almost entirely of people better than
me at both vim and q3, so I welcome your comments and criticism.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://icculus.org/pipermail/quake3/attachments/20080503/a4217b72/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: q3cfg.vim
Type: application/octet-stream
Size: 1829 bytes
Desc: not available
URL: <http://icculus.org/pipermail/quake3/attachments/20080503/a4217b72/attachment.obj>


More information about the quake3 mailing list