0

I'm writing a syntax highlighter for my test script output. I'm having problems figuring out how to find a match immediately after another match. In the screenshot, notice the $VAR1... is not highlighted at the bottom of the screenshot.enter image description here

The warning region overlaps the dump region by one character so I try to back up the warning region by one character but it doesn't work. Maybe I'm misunderstanding how that is supposed to work. Here is my script:

syn match Good "^ok "
syn match Bad  "^not ok "
syn region okline contains=Good start="^ok" end="\n"
syn match comment "^#.*\n"
syn region dump start="^$VAR" end="\s\+};\n\|;\n"
syn region warning contains=Bad start="^not ok" end="^[^#]"re=e-1,he=e-1
syn match divider "----*"
hi Good cterm=bold ctermfg=Green
hi swear ctermbg=red
hi divider cterm=bold ctermfg=yellow ctermbg=black
hi dump ctermfg=LightBlue
hi okline ctermfg=Green
hi comment ctermfg=Cyan
hi warning cterm=bold ctermfg=Red
hi big_warning cterm=bold ctermfg=Red
hi Bad cterm=bold ctermfg=Red
0

Stumbled on the answer after some more searching:

syn region warning contains=Bad start="^not ok" end="^\ze[^#]"re=e-1,he=e-1

Had to slap a \ze in there. See Can vim syntax regions be made to touch/overlap? for reference.

Not the answer you're looking for? Browse other questions tagged or ask your own question.