Hinrik Örn Sigurðsson wrote: > I don't know if I've hit a bug/limitation in vim or that I'm just > doing this wrong, but here goes. I'm trying to highlight Perl 6's POD > format as described here: > http://perlcabal.org/syn/S26.html
I haven't bothered to look at this, but only at your example. > I'm having trouble with nested =begin/=end blocks. Specifically, I > want to be able to highlight parts of the =begin/=end lines > differently, however, it seems that the only way to highlight the > start/end of a nestable region is by using the 'matchgroup' option. > But that puts the whole=begin/=end line under the same highlighting > group. If I define the region without using matchgroup and then make > it contain an item which matches the =begin/=end lines to customize > the highlighting, it messes with nesting. Yeah, this sort of thing is really awkward, but you can do it by nesting regions within regions in strange ways. The idea is to make an 'outer' region which matches where you want, include an 'inner' region in it that matches anything (i.e. the thing directly after the begin pattern), and make sure that inner region is in a cluster so it isn't matched anywhere else. I came across this kind of approach when working with #ifdef 0 highlighting in C. I've made a simple (?!) kind of example of how it can be made to work and put it below along with my test text and a picture of it as an attachment (really slow and cruddy to keep size down). It has lots of subtleties to it and it would take me all night to explain them all--it took me a good amount of trial and error to even remember how to get all the bits kinda working together. So, I refer you to the Vim help to assist with things you aren't sure of as a first port of call, and then do write back for further help if you need it, preferably being as specific as possible! I also highly recommend Dr. Chip's hilinks plugin available here: http://mysite.verizon.net/astronaut/vim/ called HiLinkTrace. You install it and, having placed the cursor on any character, type \hlt (four characters) to see how the highlighting is working for that character. Ben. syn clear syn region myOuterRegion \ matchgroup=myBeginEnd \ start=/^\s*begin\>/ \ end=/^\s*end\>/ \ contains=myInnerRegion syn region myInnerRegion \ matchgroup=myBeginEndType \ start=/\k\+/ \ end=/^\ze\s*end\>/ \ contains=myInnermostRegion \ contained syn region myInnermostRegion \ matchgroup=myBeginEndParams \ start=/^\|[^#]*/ \ end=/^\ze\s*end\>/ \ contains=ALLBUT,@Abnormal \ contained syn region myEndRegion \ start=/\(^\s*end\>\)\@<=/ \ end=/\ze#\|$/ syn match Comment /#.*/ syn cluster Abnormal \ add=myInnerRegion \ add=myInnermostRegion syn keyword Keyword key word hi link myBeginEnd Keyword hi link myBeginEndType Type hi link myBeginEndParams Identifier hi link myEndRegion myBeginEndType Here is a key and a word begin block parameters # Comment A key and a word in a block begin block2 parameters Another key and another word end block2 Blah blah blah end abcd # Comment --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
<<inline: Picture 8.png>>
