So a while ago I had decided to learn more about how vim's syntax files work, by creating my own. My goal was to create a simple syntax file that would split the file into 3 parts based on delimiters, and include pre-existing syntax files for two of those three parts.
This is an example file:
Some text, unstyled ==================== Log (Output of git log) ==================== Diff (Output of diff)
The goal was to apply
git.vim to just the log, and
diff.vim to just the diff, excluding the two headers.1 This is what my syntax file ended up looking like:
if exists("b:current_syntax") finish endif syntax include @gitlog $VIMRUNTIME/syntax/git.vim syntax region GitLog \ start=/^===* Log/ \ end=/^===* Diff/ \ contains=@gitlog syntax include @gitdiff $VIMRUNTIME/syntax/diff.vim syntax region Diff \ start=/^===* Diff/ \ end=/\n\n/ \ contains=@gitdiff let b:current_syntax = "logdiff"
end on the first region is the same as
start on the second region. This doesn't work; the second region is apparently not detected and syntax highlighting is not applied.
I can make it work by loosening the regex to
start=/=== Diff/, so that the regions don't touch, but don't particularly like that - it's less obvious that one is supposed to start where the other ends.
Is there a way to allow two region definitions to touch the same characters (and/or make the matching edges exclusive instead of inclusive) or am I stuck with the looser regex?
1(Yes, I know
diff.vim, but this was a learning exercise)