I want to syntax highlight a header region in custom style and a body region with the existing markdown style:
Title: Test Note
Id: 147648d8-8680-4847-8f50-dd4a67f870b5
Created-At: 2018-02-26 22:44:20.784550+00:00
Updated-At: 2018-02-26 22:44:20.784550+00:00
# A heading
Some text
The common start and end of the regions Header
and markdownBody
is the blank line. I tried this:
syn match HeaderValue contained '.*$'
syn match HeaderKey contained '^.*:' nextgroup=HeaderValue
syn region Header start="\%^" end="\ze\n\n" transparent contains=HeaderKey
unlet! b:current_syntax
syn include @MARKDOWN syntax/markdown.vim
let b:current_syntax = "mystyle"
syn region MarkdownBody start="\n\n" end="\%$" contains=@MARKDOWN
hi def link HeaderKey Type
hi def link HeaderValue Comment
This works for the header, but not for the body. If I replace the two occurrences of \n\n
with, e. g., END
and replace the blank line in the text with END
, it works, though.
This seems to mean there is a special handling of \n\n
. How can I use a blank line as a start
and end
marker?