Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is a relatively easy way to have different regions in your code that use different syntax files, by using the "syntax include" command and a "syntax region" command to define each region. Below is some code I have to syntax highlight different regions of Perl, R, and Python in a single document. The 'unlet' statments are necessary because the syntax files often depend on b:current_syntax not existing when they are first run. Yours would be similar, but define the 'start' and 'end' for the jinja and javascript regions using the delimiters you listed in your question. Check help for "syn-region" and "syn-include" to get more info:</p> <pre><code>let b:current_syntax = '' unlet b:current_syntax syntax include @Perlcode $VIMRUNTIME\syntax\perl.vim syntax region rgnPerl start='^src-Perl' end='^end-Perl' contains=@Perlcode let b:current_syntax = '' unlet b:current_syntax syntax include @rinvim $VIMRUNTIME\syntax\r.vim syntax region rgnR matchgroup=Snip start="^src-R" end="^end-R" keepend contains=@rinvim let b:current_syntax = '' unlet b:current_syntax syntax include @python $VIMRUNTIME\syntax\python.vim syntax region rgnPython matchgroup=Snip start="^src-Python" end="^end-Python" keepend contains=@python let b:current_syntax='combined' </code></pre> <p>I'm not sure about how to get different auto-indenting in the regions, that's a question I was going to look into myself. I think one solution would be to consolidate all of the languages indent files into one and have an if structure that processes according to which region it finds itself in. Maybe there's a simpler way than that, though.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload