Since I'm now doing some serious work with Template Toolkit for the first time, I thought it would be nice to have my editor, Vim, do pretty highlighting of the template code. It makes it easier to read.
Unfortunately Vim doesn't currently (as of version 6.4) have syntax files for TT, but there are some available separately from the site, for TT version 2 templates.
For some reason the files are in DOS format, even in the tarballs
(at least in version 0.1.2). If you're not on Windows, convert
them to Unix or Mac format by loading each of the two files, doing
set ff=unix or whatever, and saving. If you don't do that
Vim will get grumpy when it tries to load them. While you're at it,
comment out the echo line in tt2.vim, because the
message it prints gets in the way when loading files.
Put the two files, tt2.vim and tt2html.vim,
your Vim syntax directory. That will probably be
~/.vim/syntax/ under Linux and Unix. The two new filetypes
should then be available for you to set with the setf command.
For example, you can load a
template file and do setf tt2 to just highlight the templating
commands, or setf tt2html if you're templating HTML.
To have the file type set automatically for a particular file extension, create a file called something like ~/.vim/ftdetect/tt2.vim and put a line like this in it (changing the .tt extension if you want):
au BufNewFile,BufRead *.tt set filetype=tt2html
For some reason using setf here, as suggested by the install
instructions, doesn't seem to work, but setting the filetype
option does.