Hi Marc,

I am assuming that you have output like this:

  -------------------------------------------
  | Field1 | Field2 | Field3 | Field4 | ... |
  -------------------------------------------
  | Value1 | Value2 | Value3 | Value4 | ... |
  -------------------------------------------

In which case you might want to try something like this:

  syntax match Border '^-\+$'
  syntax match Border '^|' nextgroup=Col1
  syntax match Col1 '[^|]\+|' contained nextgroup=Col2
  syntax match Col2 '[^|]\+|' contained nextgroup=Col3
  syntax match Col3 '[^|]\+|' contained nextgroup=Col4
  syntax match Col4 '[^|]\+|' contained [ ... etc ... ]

  syntax match Border "|" contained containedin=Col1,Col2,Col3,Col4

  hi link Border Error
  hi link Col1 Macro
  hi link Col2 Type
  hi link Col3 Statement
  hi link Col4 String
  [ ... etc ... ]

This should highlight each column in a different color for you.  In case this
doesn't help you, the following might help you:

  - using '^' in your pattern means it can *only* match at the beginning of the
line

  - you don't need to use \ze at the end of your pattern.  Typically \ze is
used when you want the match to end there, but you want to make sure some other
things following \ze also match.  'foo\zebar' matches and 'foo', but only if it
is followed by 'bar'.

  - rather than adding the whole '<skip over first col>' pattern stuff to the
Color2 match, why not add 'nextgroup=Color2' to the end of the Color1 match?

HTH,
regards,
Peter


--- Marc Weber <[EMAIL PROTECTED]> wrote:

> background:
> I want to highlight columns in a table differently (database output)
> So 1 and 2 will be substituted by either \t or |.
> 
> ============= syntax file
> ======================================================
> hi def link Color1 Macro
> hi def link Color2 Error
> 
> "Show colors of Color1, Color2
> syn keyword Color1 A
> syn keyword Color2 B
> 
> syn match Color1 '^1\zs[^1]*\ze'
> syn match Color2 '^1[^1]*1\zs[^1]*\ze'
> syn match Color2 '^2[^2]*2\zs[^2]*\ze'
> 
> ============= testfile
> =========================================================
> A 
> B 
> 1aa1bb    
> 2cc2dd    
> 
> explanation lines testfile:
> Line 1 testline to show Color1
> Line 2 testfile to show Color2
> Line 3 Here aa and bb should be highlighted with Color1, Color2 ( bb isn't)
> Line 4 only dd should be highlighted to show that the match pattern
> works (only difference is 2 instead of 1)
> 
> Marc
> 


Send instant messages to your online friends http://au.messenger.yahoo.com 

Reply via email to