syntax.html gives an example of a PHP heredoc in which the end of the heredoc is matched using
\1 used to match a previously captured pattern.
I tried to do something similar in order to set a scope name according to a previously matched pattern
- match: "^\\s*([a-z.]+): .* // (.*)"
the idea was to have a custom syntax for a .myScheme file (from which a standard tmScheme file would be generated), The source would preview itself in the comments.::
meta.diff.header: #ffffff/#4e738a // --- D:\st3portable\Data\Packages\MyScheme\x.txt
meta.diff.range: #888888 <i> // @@ -34,6 +34,5 @@
The first // comment would have scope name meta.diff.header and be shown as white text on a different background and the second comment would have scope meta.diff.range and text shown in grey italics.
(BTW: my suggestion is that \1 etc be allowed in the captures: list, unless it would open up a horrible can of worms)
ETA: I just noticed the suggestion for a YAML based format for tmscheme which would make my plugin immediately redundant. However maybe the YAML-solution could benefit from such a change.