Answer the question
In order to leave comments, you need to log in
How to properly set up Template Toolkit syntax highlighting in Vim?
Here is a Vim script www.vim.org/scripts/script.php?script_id=830 that does this. I added it to the syntax folder, added the necessary lines to filetype.vim:
au BufNewFile,BufRead *.tt2 call s:AdjustTT2Type()
func! s:AdjustTT2Type()
if ( getline(1) . getline(2) . getline(3) =~ '<\chtml'
&& getline(1) . getline(2) . getline(3) !~ '<[%?]' )
|| getline(1) =~ '<!DOCTYPE HTML'
setf tt2html
else
setf tt2
endif
endfunc
To define START_TAG and END_TAG you like, you can set any pair of tags to 'b:tt2_syn_tags':
"ASP"
:let b:tt2_syn_tags = '<% %>'
"PHP"
:let b:tt2_syn_tags = '<? ?>'
"TT2 and HTML"
:let b:tt2_syn_tags = '\[% %] <!-- -->'
<html>
<body>
<ul>
[% FOREACH num IN [1..10] %]
<li>num: [% num %]</li>
[% END %]
</ul>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question