I have a question regarding syntax matching. I have some kind of syntax and I have some solution to highlight it, but it does not work the way I expect it to.

What I want: match syntax that consists of blocks (enclosed in {}), strings (enclosed in "") and identifiers (starts with ${ and ends with }). Block end should also end any string that starts inside this block.

My solution:

:syn cluster Top contains=Block,String,Identifier
:syn region Block start=+{+ end=+}+ keepend extend [EMAIL PROTECTED]
:syn region String start=+"+ end=+"+ contains=Identifier
:syn region Identifier start=+\${+ end=+}+ extend

Here is a sample that shows that this solution does not work:

 "string ${var} string"

For some reason an Identifier region ends a String region and a second word 'string' is not highlighted as a string (and Vim says that it has Block match there).

Question: why the String region is not restored after the Identifier region ends?

P.S. Removing keepend from a Block makes highlighting right in this example but then an important point that Block should end unmatched String is lost.

P.P.S. Solution code is in 1.vim and test code is in 1.vim.test so you may try it on your vim with

   vim -s 1.vim 1.vim.test


Attachment: 1.vim
Description: application/octetstream

  "string ${var} string"

Reply via email to