가 여기에 contains=...
및 contained
키워드를 사용하여, 그것을 할 수있는 한 방법입니다 :
" Add some highlight defs:
hi link MyLeftPart SpecialKey
hi link MyMinus Operator
hi link MyRightPart String
" Match the whole lines, and make the given highlight work only
" with lines with this format: "x - blah blah..." :
syn match MyLeftPart /^. - .*/ contains=MyMinus
" Leave the very first char highlighted with MyLeftPart, and
" highlight the rest with MyMinus:
syn match MyMinus /.\zs.*/ contains=MyRightPart contained
" Leave the minus highlighted with MyMinus, and highlight the rest
" with MyRightPart:
syn match MyRightPart/- \zs.*/ contained
당신이 더 \s\+-\s\+
에 의해 -
를 대체하여 (예를 들어, 사용자의 요구에 맞게 세 가지 주어진 패턴을 수정할 수 있습니다 물론을, 또는 오른쪽으로 이동 한 선을 사용하여 강조 표시를 적용하려면 ^
을 제거하십시오.
:syn match
대신 matchadd()
함수를 사용하는 것과 같은 다른 솔루션을 선호 할 수도 있습니다.
"repectively"는 무엇을 의미합니까? 글자로 시작하는 모든 줄을 일치시킨 다음 빼기 부호를 찾으시겠습니까? 또는 마이너스 기호 앞과 뒤의 글자를 다르게 강조하고 싶습니까? – yolenoyer
@yolenoyer 나는 세 개의 섹션을 강조하고 싶다 : 빼기 기호, 그 앞과 뒤. 그리고 나는 현재 마이너스 기호를 강조하는 데 성공합니다. – Jimmy