3

I am trying to highlight lines like these:

-> Some text without a domain
-> Some other text with a domain (example.com)

I would like:

a) the leading "->" not to be highlighted; b) the text to be highlighted with, say, Underlined; c) and the domain if given to be highlighted with, say, Comment.

This achieves (a) and (b) but not (c):

syntax region MyLink start=/^-> /hs=e end=/\v(\s\(\a+[.]\a{2,3}\))?$/he=s-1
highlight link MyLink Underlined
syntax match Domain /\v\(\a+[.]\a{2,3}\)/
highlight link Domain Comment

I have tried add contained and contains etc but haven't quite found the right answer.

Any help much appreciated!

2

You were on the right track! You just need to either:

Add containedin=MyLink to your definition of Domain:

syntax match Domain /\v\(\a+[.]\a{2,3}\)/ containedin=MyLink

or:

Add contains=Domain to your definition of MyLink:

syntax region MyLink start=/^-> /hs=e end=/\v(\s\(\a+[.]\a{2,3}\))?$/he=s-1 contains=Domain

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.