: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?
1 Answer
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.
Normal
will do the trick?