[EMAIL PROTECTED] wrote:

Hi vimmers, I've got some question when writing my syntax highlight script.

Q1.
The language requires a ^M character as a keyword. The ^M character is by
default highlighted but I want to highlight it to some other color, at
least it should be different from ^L and ^N...

It seems impossible to match the ^M by
:syn match Testgroup "^M"
(Note the ^M is obtained by press C-K, release, then press C-M, release,
then press <Enter>)
and
:hi def link Testgroup Number
does not highlight it as desired. It seems always highlighted to some other
color.

Looks like you've got a problem; the SpecialKey highlighting (see :he hl-SpecialKey) currently can't be overridden with syntax highlighting. It does appear that the :match (and friends :2match and :3match) can override the SpecialKey highlighting for a specific control character. This problem is mentioned in :help todo , line#1482 (using vim 7.0's help). As an example for how to use :3match:

:3match Testgroup /\%x0d/

Q2.
The string for the script language can be as long as 50-100 lines, when I
write a ":syn region" for string, it works but sometimes when I go page
down and page up, the lines of the string are highlighted as "Normal"
instead of "String", seems that the context are not concerned. Any work
around?
:help syn-sync

Q3.
The first occurence of colon and the following occurences in a line have
different meanings.
So, if there are text: yyyy:xxxx:aaaa:bbbb;
I want to highlight the first colon as GroupA, and highlight all following
occurences of colon in the same line as GroupB. Is that possible?
Sure!  Here's an example summarizing the above:

" ------------------------------------------------------------------------
syn clear
syn sync fromstart

syn region Colons matchgroup=FirstColon start=':' end='$' contains=MoreColons
syn match MoreColons ':' contained

hi link Ctrlm      Red
hi link FirstColon Magenta
hi link MoreColons Yellow

3match Ctrlm /\%x0d/
" ------------------------------------------------------------------------

Regards,
Chip Campbell

Reply via email to