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
syntax vim php


source to share


No one has answered this question yet

Check out similar questions:

3487
How do I exit the Vim editor?
1954
What is the preferred syntax for defining enums in JavaScript?
1757
Vim clear last search
1741
How to replace a character with a newline in Vim
1530
Duplicate a whole line in Vim
1330
How does vim's "write with sudo" trick work?
1214
How to do case insensitive search in Vim
1127
What's the best combination with Vim you have?
1065
Link. What does this error mean in PHP?
962
How to efficiently handle multiple files in Vim?



All Articles
Loading...
X
Show
Funny
Dev
Pics