I have a line-delimited language syntax containing a command that allows multi-line strings, similar to how Python handles '''...''' and """...""" constructs.
I want to define a region within that is delimited by the triple quotes, but which does not itself include the triple quotes. The gist of the problem: define the file bar.txt containing the following:
foo [other stuff] bar '''
more stuff
'''
The triple quotes end the line in both cases. I want the entire thing to be one region, and within that region, the triple-quoted text should be another region. The following syntax highlighting file (which I called "test.vim") almost does what I want it to do:
syntax region specialCommand start='\<foo\s' end='$' skip='&$'
\ keepend contains=tripleQuoted
syntax region tripleQuoted start=+\<bar\s\+\z("""\|'''\)+ms=e+1
\ end='\ze\z1' contained extend
hi def specialCommand ctermbg=gray guibg=lavender
hi def tripleQuoted ctermbg=lightgray guibg=pink
If you then issue ":source test.vim" (or otherwise set the syntax highlighting to include the lines above), I get only the first line contained within specialCommand and nothing within tripleQuoted. If I put a space after the first ''', however, I get the first line highlighted as specialCommand (except the final space), the entire second line highlighted and the space after the first triple quote as tripleQuoted, and the last line highlighted as part of specialCommand again.
The desired behavior is to have everything within the quotes highlighted as tripleQuoted, and everything else highlighted as specialcommand.
Put another way; it looks like this:
foo [other stuff] bar '''
more stuff
''' still more stuff
and it should look like
foo [other stuff] bar '''
more stuff
''' still more stuff
where boldface denotes the specialCommand region and italics denotes the tripleQuoted region. Adding a space after the first ''' makes it work as expected.