smaili
smaili

Reputation: 1235

Combining multiple syntaxes in MacVim

I'm trying to create a custom syntax highlighter for MacVim that uses a combination of CSS and PHP, where CSS is static selectors, and sometimes there will be embedded PHP code (very similar to HTML+PHP).

Here is my syntax file:

"Import CSS first
runtime! syntax/css.vim
unlet b:current_syntax

" Use PHP any time there is <? ?>
syn include @syntaxPHP syntax/php.vim
syn region regionPHP start="<?" end="?>" contains=@syntaxPHP

When I open the following:

.my-css {
    <?php echo 'my-php'; ?>
}

Only the php part is colored, the css is not.

Upvotes: 2

Views: 76

Answers (1)

svlasov
svlasov

Reputation: 10455

Use containedin=ALL:

syn region regionPHP start="<?" end="?>" containedin=ALL contains=@syntaxPHP

enter image description here

Upvotes: 1

Related Questions