2021年4月23日星期五

How to define vim color highlight region consisting of single line matching certain pattern

I would like to color each digit in its own color, but only if this digit is part of a "digitmap" and not in a regular text. In this example, the "DigitMap" region should be any line that possibly starts with " and contains nothing else but digits and spaces. I know how to define region using start and end, but this does not work for large digitmaps.

syn region DigitMap start="+++" end="---" contains=m0,m1,m2,m3,m4,m5  syn match m0 "0" contained  syn match m1 "1" contained  syn match m2 "2" contained  syn match m3 "3" contained  syn match m4 "4" contained  syn match m5 "5" contained    hi clr1 guibg=#e41a1c ctermbg=196  hi clr2 guibg=#377eb8 ctermbg=68  hi clr3 guibg=#4daf4a ctermbg=77  hi clr4 guibg=#984ea3 ctermbg=133  hi clr5 guibg=#ff7f00 ctermbg=208  hi clr6 guibg=#ffff33 ctermbg=227    hi def link DigitMap clrBrewerNone  hi def link m0 clr1  hi def link m1 clr2  hi def link m2 clr3  hi def link m3 clr4  hi def link m4 clr5  hi def link m5 clr6  " +++  " 003300311111041000000000011000000200011112103333312233433333311222222010000000  " 123332300000041303111122211200001200011102103333311033443000211111115015210001  " 123332311021041333333222211233331200020133133333210033444423211111105015210001  " 123332322021041333333222221212400200020222220222200033444423211112105555510000  " 003112344444444322222222100002445002222222240112201033401011111332105555412211  " 213002311144442222222222111014445502222220044444400033400000011332555550444311  " 111111300003002000022222123312355222222221240444101030000000111330020350410311  " ---  
https://stackoverflow.com/questions/67238463/how-to-define-vim-color-highlight-region-consisting-of-single-line-matching-cert April 24, 2021 at 09:08AM

没有评论:

发表评论