开发者

In a VIM syntax file how can I use a start match in the end match?

In VIM syntax files one can write a s开发者_如何学编程yntax region match like this:

syn region xqString start=+'+ end=+'+
syn region xqString start=+"+ end=+"+

What I want to write instead is

syn region xqString start=+(['"])+ end=+\1+

where \1 is the match found in start. Any answers on how to do this or if it's not possible?


See :help :syn-ext-match

External matches :syn-ext-match

These extra regular expression items are available in region patterns:

        */\z(* */\z(\)* *E50* *E52*
\z(\) Marks the sub-expression as "external", meaning that it is can
be accessed from another pattern match.  Currently only usable
in defining a syntax region start pattern.

      */\z1* */\z2* */\z3* */\z4* */\z5*
\z1  ...  \z9     */\z6* */\z7* */\z8* */\z9* *E66* *E67*
Matches the same string that was matched by the corresponding
sub-expression in a previous start pattern match.

So you could do syn region xqString start=+\z(['"]\)+ skip=+\\.+ end=+\z1+

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜