matching start
pattern. There is no check for a matching end pattern. This does NOT
work: >
:syn region First start="(" end=":"
:syn region Second start="(" end=";"
< The Second always matches before the First (last defined pattern has
higher priority). The Second region then continues until the next
';', no matter if there is a ':' before it. Using a match does work: >
:syn match First "(\_.\{-}:"
:syn match Second "(\_.\{-};"
< This pattern matches any character or line break with "\_." and
repeats that with "\{-}" (repeat as few as possible).
*:syn-keepend*
By default, a contained match can obscure a match for the end pattern.
This is useful for nesting. For example, a region that starts with
"{" and ends with "}", can contain another region. An encountered "}"
will then end the contained region, but not the outer region:
{ starts outer "{}" region
{ starts contained "{}" region
} ends contained "{}" region
} ends outer "{} region
If you don't want this, the "keepend" argument will make the matching
of an end pattern of the outer region also end any contained item.
This makes it impossible to nest the same region, but allows for
contained items to highlight parts of the end pattern, without causing
that to skip the match with the end pattern. Example: >
:syn match vimComment +"[^"]\+$+
:syn region vimCommand start="set" end="$" contains=vimComment keepend
< The "keepend" makes the vimCommand always end at the end of the line,
even though the contained vimComment includes a match with the <EOL>.
When "keepend" is not used, a match with an end pattern is retried
after each contained match. When "keepend" is included, the first
encountered match with an end pattern is used, truncating any
contained matches.
*:syn-extend*
The "keepend" behavior can be changed by using the "extend" argument.
When an item with "extend" is contained in an item that uses
"keepend", the "keepend" is ignored and the containing region will be
extended.
This can be used to have some contained items extend a region while
others don't. Example: >
:syn region htmlRef start=+<a>+ end=+</a>+ keepend contains=htmlItem,htmlScript
:syn match htmlItem +<[^>]*>+ contained
:syn region htmlScript start=+<script+ end=+</script[^>]*>+ contained extend
< Here the htmlItem item does not make the htmlRef item continue
further, it is only used to highlight the <> items. The htmlScript
item does extend the htmlRef item.
Another example: >
:syn region xmlFold start="<a>" end="</a>" fold transparent keepend extend
< This defines a region with "keepend", so that its end cannot be
changed by contained items, like when the "</a>" is matched to
highlight it differently. But when the xmlFold region is nested (it
includes itself), the "extend" applies, so that the "</a>" of a nested
region only ends that region, and not the one it is contained in.
*:syn-excludenl*
When a pattern for a match or end pattern of a region includes a '$'
to match the end-of-line, it will make a region item that it is
contained in continue on the next line. For example, a match with
"\\$" (backslash at the end of the line) can make a region continue
that would normally stop at the end of the line. This is the default
behavior. If this is not wanted, there are two ways to avoid it:
1. Use "keepend" for the containing item. This will keep all
contained matches from extending the match or region. It can be
used when all contained items must not extend the containing item.
2. Use "excludenl" in the contained item. This will keep that match
from extending the containing match or region. It can be used if
only some contained items must not extend the containing item.
"excludenl" must be given before the pattern it applies to.
*:syn-matchgroup*
"matchgroup" can be used to highlight the start and/or end pattern
differently than the body of the region.