Understanding vim syntactic offsets

I have a lot of problems with syntax offsets and I don't understand the explanations given in the Vim help docs.

My PHP ftplugin has the following:

syntax region mySQLRegion
  \ contains=@SQLSyntax
  \ containedin=phpRegion
  \ contained
  \ matchgroup=sqlDelim
  \ start=+\vSQL\("$+
  \ end=+^\s*"[,)]+
  \ keepend

      

I want to combine the construction of the code like this:

... SQL("
    ...my sql here...
", ...

      

This is currently working. But I want the highlighting to be done strictly between the two separator lines - in other words, I want the leading SQL("

and closing ones to ",

be highlighted using standard PHP highlighting.

I've tried a few different offsets permutations, but either the rest of the file gets colored with SQL highlighting, or the SQL block gets colored as a PHP string. I'm looking for both an answer to this question in particular, and for a more general explanation of how to think about when to use ms

/ me

vs. rs

/ re

vs. hs

/ he

when it would be appropriate to use either =s+/-{nr}

or =e+/-{nr}

in these contexts. I understand that it must be a match, area and selection, and that the start and end of the match are offset by a number of characters in either direction, but I clearly don't understand it properly because none of my attempts have been successful.

Link

+3


source to share





All Articles