:h region bring me very little help. I need to exclude a pattern inside a region that should be ignored for example: don't apply match/highlight begin from # to the end of line $
I try to ignore #.*$ inside a region but seem I can't find anything related from help. Did I miss something from docs?
Or if I need to write a function to do that, do you have any suggestions?

  • Not sure if that is possible. As a workaround maybe creating a subregion and linking it to for example Normal will do the trick? – grodzik Nov 7 '17 at 9:41

Create a testing file with the following contents:

# foobar

    # foo

    # bar

First solution

:syn Comment /#.*$/
:syn myRegionWithoutComment start='{' end='}'
:syn myRegionWithComment start='[' end=']' contains=ALL

Second solution

Try :h syn-skip.

skip={skip_pattern} The search pattern that defines text inside the region where not to look for the end.

See Learn Vimscript the Hard Way, Even More Advanced Syntax Highlighting for an example.

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.