1

I'm trying to learn multi line highlighting and have managed to get the following working

syntax region myMinusStart start=/^\s\+zzzz / end=/^\s\+qqqq / concealends

But the concealends is not hiding the line with zzzz $ or the line with qqqq $

Reading `:h :syn-concealends' it seemed to say that to conceal the ends they need a match group so I tried

syntax match myMinusBegin /^\s\+zzzz / contained conceal
syntax match myMinusEnd  /^\s\+qqqq /  contained conceal

example

But the start line still didn't conceal. Any suggestions?

Update: For some reason the zzzz is reporting as MyMinusStart which would suggest why it's not concealing.

I also tried the following thinking the pattern had to differ but with no luck

syntax match myMinusBegin /^\s\+zzzz / contained conceal
syntax match myMinusEnd  /^\s\+qqqq /  contained conceal

Update I tried Karl's suggestion, below, and that hid the start and end markers but after removing transparent, as it hid the color highlighting , there's a termination problem in the pattern I can't work out

Karl's suggestion syntax region myMinusStart start=/^\s+zzzz / end=/^\s+qqqq / \ transparent \ contains=myMinusBegin,myMinusEnd

syntax match myMinusBegin /^\s\+zzzz / contained conceal
syntax match myMinusEnd  /^\s\+qqqq /  contained conceal

Example 1

For some reason once I enter zzzz $ and qqqq $ once it color hilights to the end of the file. There are three blocks that match the region but I can't see why the coloring continues until file end.

1 Answer 1

4

Try the following:

syntax region myMinusStart start=/^\s\+zzzz / end=/^\s\+qqqq /
      \ keepend
      \ contains=myMinusBegin,myMinusEnd

syntax match myMinusBegin /^\s\+zzzz / contained conceal
syntax match myMinusEnd  /^\s\+qqqq /  contained conceal

Note that you need to set conceallevel e.g. to 2, see :h conceallevel.

Update: A simpler alternative:

syntax region myMinusRegion matchgroup=myMinusDelim
      \ start=/^\s\+zzzz / end=/^\s\+qqqq /
      \ concealends

Of course, if you want the start and end matches to be highlighted differently, then the original version is necessary.

4
  • Karl thanks. That almost worked , removing the transparent as that removed the coloring, but there's a pattern end problem. See update
    – Steve
    Mar 9, 2018 at 0:25
  • try to add the option keepends to the syntax region command. Mar 10, 2018 at 8:56
  • Do you mean keepend not keepends?
    – Jan
    Nov 27, 2020 at 8:41
  • 2
    Yes @Jan, you're right. I've also updated to add a better version. Nov 27, 2020 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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