In my syntax description file I'm trying to define something like the followingsyn match arbSAMPLEop   \<\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\>syn match arbTexTarget     \<\(1D\|2D\|3D\|CUBE\|RECT\)\> containedsyn region arbSampleInstruction start=\<\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\> end=; contains=arbSAMPLEop,arbTexTargetThis allows to highlight texture sampling instructions and texture targets only inside the region started by a sampling instruction.What bothers me is that the region starts by arbSAMPLEop, but the string to define arbSAMPLEop is copy-pasted as the start= pattern. Is there any way I could achieve the same without duplicating the string?
How to avoid repeating pattern strings in syntax files?
syntax highlighting
Try:syn match arbTexTarget \<\(1D\|2D\|3D\|CUBE\|RECT\)\> containedsyn region arbSampleInstruction matchgroup=arbSAMPLEop start=\<\(TEX\|TEX_SAT\|TXP\|TXP_SAT\|TXB\|TXB_SAT\)\> end=; contains=arbTexTargetmatchgroup allows highlighting the delimiting patterns ofa region separately from the body of the region.:help syn-matchgroupIf you really had to, you could store a pattern in a string variable, and then use execute to build up your syntax command. However I doubt this is necessary in a well-structured syntax file.