1

Following my previous question, I have the same string aaabbbb that I am colorizing in the same way, except with the addition that I am now also trying to conceal the as.

Here is the best that I got so far:

" here xB is not matched
syntax match xA /^a\+/ conceal transparent
syntax match xB /\(^a\+\)\@<=b\+/
highlight xA ctermfg=red
highlight xB ctermfg=blue

But the problem is that, while the as get concealed as expected, they don't get colorized.

But, if I remove the concealment, colorization works fine. I.e. this colorizes just fine (but obviously doesn't conceal the as):

" here xB is not matched
syntax match xA /^a\+/
syntax match xB /\(^a\+\)\@<=b\+/
highlight xA ctermfg=red
highlight xB ctermfg=blue

Q1: How to colorize and conceal at the same time?

Q2: I feel that I am missing some fundamental knowledge about how vim applies match/highlight. What is going on here? Is the concealment causing vim to not see the text during the syntax highlighting stage? I mean, it's the same match statement. So vim saw the text and applied the concealment, but somehow thought to not apply the color to it. What's am I missing in the internal vim workflow?


Update: This seems to work, but I am not sure why.

" here xB is not matched
syntax match xA /^a\+/
syntax match xB /\(^a\+\)\@<=b\+/
highlight xA ctermfg=red
highlight xB ctermfg=blue
syntax match xAConceal /^a\+/ conceal transparent
2

IIRC, transparent prevents coloring the text in any ways.

I would expect the following to work

syntax match xA /^a\+/ conceal
syntax match xB /\(^a\+\)\@<=b\+/
highlight xA ctermfg=red
highlight xB ctermfg=blue
  • Ooo. YES. I'm DUMBIE. Thanks! – caveman Jan 5 at 15:37

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.