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

5

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 Commented Mar 9, 2018 at 0:25
  • try to add the option keepends to the syntax region command. Commented Mar 10, 2018 at 8:56
  • Do you mean keepend not keepends? Commented Nov 27, 2020 at 8:41
  • 2
    Yes @Jan, you're right. I've also updated to add a better version. Commented Nov 27, 2020 at 10:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.