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 a
s.
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 a
s 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 a
s):
" 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