Fernando Basso wrote:
I have a little syntax file, with lines like:

     highlight sExamplesInText ctermfg=yellow guifg=yellow
     syntax match sExamplesInText /«\zs[^»]\_.\{-}\ze»/

I'd like to use « and » to delimit the text I want to be yellow, but
also, to hide those delimiters.

I tried:

     syntax match Conceal /«\|»/ conceal

but that seems not to be the right thing (I did set conceallevel=2).

So, text inside « and » characters should be yellow (or any other
color). But the delimiter should be hidden. What is the way to go?

Please try:

syn clear
set cole=3
syn match DelimHide1      /«/           nextgroup=sExamplesInText conceal
syn match sExamplesInText /\_.\{-}\ze»/ contained nextgroup=DelimHide2
syn match DelimHide2      /»/           contained                 conceal
hi  sExamplesInText ctermfg=yellow guifg=yellow

You may find hilinks of help with your syntax work...

   http://drchip.0sites.net/astronaut/vim/index.html#HILINKS

This plugin provides the :HLT! command -- with it you'll get a syntax stack trace and a highlighting stack trace as you move your cursor about.

The problem you've had with your syntax highlighting is one with priority and sequentiality:

* With the following sequence, the « has already been taken up

syntax match Conceal /«\|»/ conceal
syntax match sExamplesInText /«\zs[^»]\_.\{-}\ze»/

 by the sExamplesInText, as it has priority due to appearing later (sequence), so 
"Conceal" never sees it (assuming balanced «...» delimiters so that 
sExamplesInText matches).

* With the following sequence, the « has already been taken up

syntax match sExamplesInText /«\zs[^»]\_.\{-}\ze»/
syntax match Conceal /«\|»/ conceal

 by the "Conceal", as it has priority due to appearing later (sequence); this 
time, sExamplesInText never sees the character and so never matches.

HTH,
Chip Campbell



--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to