On Thursday, September 18, 2014 6:39:03 AM UTC-5, RedX2501 wrote:
> Hello,
> 
> 
> 
> I'm wondering what the proper way is to highlight an identifer
> 
> followed by 3 numbers:
> 
> 
> 
> syn cluset asapNumber=asapInteger,asapHex
> 
> 
> 
> syn match 'MATRIX_DIM' nextgroup=asapNumber
> 
> 
> 
> but the asapNumber following MATRIX_DIM must occurr exactly 3 times
> 
> and it is not relevant if it is in the same line or not.
> 
> 
> 
> What is the proper way of doing this?
> 

You probably want the "skipwhite", "skipnl", and "skipempty" items as well, to 
allow multiple lines.

I don't know if there is a "proper" way; but to allow exactly three matches, 
one way is to use multiple asapNumber groups: asapNumber1, asapNumber2, and 
asapNumber3. 2 would be in the nextGroup of 1, and 3 would be in the nextGroup 
of 2. If you like, you could even make an asapNumberError that is the nextGroup 
of 3 to highlight when there are more than 3 numbers (since you say it MUST 
occur EXACTLY three times). You could likewise make a asapNoNumberError that 
matches things that are not a number and is the nextGroup of whatever you 
called your MATRIX_DIM match, and also asapNumber1 and asapNumber2. Then you 
also highlight when you have fewer than 3 numbers.

Example (not sure how well this works with clusters):

syn match startnums 'MATRIX_DIM' nextgroup=asapNumber1,asapErrNoNumber 
skipwhite skipnl skipempty
syn match asapErrNoNumber '[^0-9 ]\+' contained
syn match asapNumber1 '\d\+' contained nextgroup=asapNumber2,asapErrNoNumber 
skipwhite skipnl skipempty
syn match asapNumber2 '\d\+' contained nextgroup=asapNumber3,asapErrNoNumber 
skipwhite skipnl skipempty
syn match asapNumber3 '\d\+' contained nextgroup=asapErrNumber skipwhite skipnl 
skipempty
syn match asapErrNumber '\d\+' contained nextgroup=asapErrNumber skipwhite 
skipnl skipempty
hi def startnums guibg=blue
hi def asapNumber1 guibg=yellow
hi def asapNumber2 guibg=yellow
hi def asapNumber3 guibg=yellow
hi def link asapErrNumber Error
hi def link asapErrNoNumber Error

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to