3

I have a syntaxfile for highlighting awk embedded in bash script:

syn include @AWKScript syntax/awk.vim
syn region AWKScriptCode matchgroup=AWKCommand
    \ start=+[=\\]\@<!'+ skip=+\\'+ end=+'+ contains @AWKScript contained
syn region AWKScriptEmbedded matchgroup=AWKCommand
    \ start=+\<\(g\?awk\|\$AWK\)\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1 
    \ contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
syn cluster shCommandSubList add=AWKScriptEmbedded
hi def link AWKCommand Type

The problem is with this section:

start=+\<\(g\?awk\|\$AWK\)\>+

It works fine for awk and gawk, but not for $AWK. How can I add a rule to match $AWK as a starting pattern for the AWKScriptEmbedded region?

aktivb
  • 1,952
  • 2
  • 15
  • 16

1 Answers1

3

The problem is that the $AWK is already highlighted by the shDerefSimple syntax group, so your new region isn't applied. Split the syntax definition into two parts and add the containedin= for the latter:

syn region AWKScriptEmbedded matchgroup=AWKCommand
    \ start=+\<g\?awk\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1
    \ contains=@shIdList,@shExprList2 nextgroup=AWKScriptCode
syn region AWKScriptEmbedded matchgroup=AWKCommand
    \ start=+\$AWK\>+ skip=+\\$+ end=+[=\\]\@<!'+me=e-1
    \ contains=@shIdList,@shExprList2 containedin=shDerefSimple nextgroup=AWKScriptCode
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
  • Works like a charm, thanks! Is this also why it won't work to include a \< in the start match, because it is contained in another region? – aktivb Dec 18 '12 at 04:53