Suppose I have these Vim definitions:

syn match tasktag "\(\s\)\@<=@[a-zA-Z0-9_]\+"
syn match taskdone "\<[Dd]one\>" containedin=tasktag

How do I specify taskdone to highlight the entire text in the line? I looked at :h syn-pattern-offset as well as :h syn-region.


First, your "tasktag" match does not allow spaces or other "word delimiters", yet your "taskdone" match requires "done" to be a discrete word because of your \< and \> word boundary atoms.

Second, your "taskdone" match is written to only highlight the word "Done".

Assuming I properly understand what you want, I modified your two matches:

syn match tasktag "\(\s\)\@<=@[a-zA-Z0-9_ ]\+"
syn match taskdone "@.*\<[Dd]one\>.*" containedin=tasktag

If you haven't done so already, you will need to specify the highlighting for the two matches. For example:

highlight link tasktag TODO
highlight link taskdone Statement

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.