Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim regex skip delimiters

I'm trying to create a vim syntax file, and I'd like to match the following bit of text:

@[one two three four]

Basically, I want to match one and two as two separate matches, and I don't care about three and four (or anything after them). I also don't want to include the @[ delimiter at the beginning of the expression.

I tried doing this with regions, like so:

syn region langParamOne matchgroup=langListStart start=/@\[/ end=/\s\|\]/
syn region langParamTwo matchgroup=langListStart start=/@\[\S\+\s\+/ end=/\s\|\]/

Unfortunately, not only does this look messy, but vim will only match one of the regions, since one contains the other.

How can I set up a match for this syntax, but not include the starting @[ in the match?

like image 889
Alexis King Avatar asked Nov 25 '25 18:11

Alexis King


1 Answers

How about this:

syn region langParam matchgroup=langListStart start=/@\[/ end=/\]/ contains=langParamOne,langParamTwo
syn match langParamOne /\(@\[\)\@<=\S\+/ contained
syn match langParamTwo /\(@\[\S\+\s\)\@<=\S\+/ contained
like image 190
Tomalak Avatar answered Nov 28 '25 17:11

Tomalak