Suppose I want to make a syntax highlighting script to work with files with the following hypothetical format:
blah # blahA1B2 bla asdf A11B453 # qwert aaa A0B0 bbb @
That is, lines with arbitrary text, but somewhere in the line I have a string with the format
A immediately followed by a number, immediately followed by
B, and then another number).
Furthermore, suppose that I highlight the whole line based on another pattern (in the example I'll make it clear).
What I want is to highlight only the numbers within the pattern
A[0-9]\+B[0-9]\+, without removing the current highlight from the
The following script almost solves my problem:
syn match Type '.*#.*' syn match Macro '.*@.*' syn match Number '[AB]\zs\d\+\ze'
What it does:
- Highlight with green lines that have a
#(this part is ok).
- Highlight with purple lines that have a
@(this part also is ok).
- Highlight the number following A or B (this need improvement).
The problem with my script is that it also highlights
B3, but they should be together to be highlighted.
I've also worked a bit with the
containedin, but with no success.