On 26/10/06, Hugh Sasse <[EMAIL PROTECTED]> wrote:
[snip]
So, we run into a problem: how does one syntax highlight mixed
language code?
[snip]

I don't know whether this is of any use, but I have often found
situations where I need to embed code from one language in the comments
of another.  For example, I have Matlab code that scans through its own
source for some perl code, writes it to disk and then uses it to process
text files (as Perl is MUCH better at text file handling).  This saves
having multiple scripts for a single (relatively simple task).  In
.vim/after/syntax/matlab.vim, I have (three lines):

unlet! b:current_syntax
syn include @matlabPerlScript $VIMRUNTIME/syntax/perl.vim
syn region matlabPerlRegion matchgroup=matlabScriptDelim start=+^%
PERL\d*: +hs=s+8 end=+$+ [EMAIL PROTECTED]

So any lines starting "% PERL: " (with an optional number after PERL)
are highlighted as perl code.  The number allows me to have multiple
perl scripts embedded in a single Matlab script.  I have done similar
things for C and others.

Hope that is of some interest,

Al

Reply via email to