tsql - Vim - custom syntax - how to match second word -
i'm trying make custom syntax highlighting sybase t-sql , i'm stuck when try match table name in following line:
update mytablename
i've tried:
syn match tsqlupdatetablename "\w\+" contained syn match tsqlupdateline "update.*" nextgroup=tsqlupdatetablename hi tsqlupdatetablename guifg=white guibg=red
but not match mytablename appreciate help. cheers!
the problem nextgroup
matches after current group's match.
you can fix excluding table name in line match, either dropping .*
or, i've done here, asserting following table name ending match \ze
:
syn match tsqlupdatetablename "\w\+" contained syn match tsqlupdateline "update \ze\w\+" nextgroup=tsqlupdatetablename
alternatively, can include table name in line match , use contains=
instead:
syn match tsqlupdatetablename "update \zs\w\+" contained syn match tsqlupdateline "update \w\+" contains=tsqlupdatetablename
ps: should tighten patterns entire-word matches, e.g. "\<update\>
; otherwise, may mistakenly match inside words catchupdate
.