On 2007-01-27, Muddassirali Mirzani <[EMAIL PROTECTED]> wrote:
> Hi,
>    I'd like to write a simple syntax file for a file
> type that is a transcript( contains only printed
> messages from a simulation) .
> I wanted to do the following :
> e.g. a) Search for string [TRACE] and colour the whole
> line in yellow
>      b) Search for string [WARNING] and colour the
> whole line in green.. and so on...
> 
> Are there any examples scripts out there.. Any
> help/pointers appreciated..

Here's a simple one that I did to highlight a similar type of file, 
the transcript of a system build script.  The types of lines 
highlighted are:

-  Comments, beginning with '#' and ending at the end of the line.
-  Commands, lines beginning with 'CMD: '.
-  Warning messages, lines containing the word 'warning' in any 
   capitalization.
-  Error messages, lines containing the word 'Error'.
-  Build summaries, multiple lines beginning with the line 'b
   '=== Build Complete ===' and ending with a blank line or the end 
   of the file.

To set the colors, I gave each pattern a syntax group name, 
following what appears to be the standard vim naming convention of 
using the plugin or language name followed by a description of the 
syntax element.  I then assigned each of my syntax groups to an 
existing vim syntax group.  I chose the colors by executing ":hi" 
and selecting the syntax groups whose color I liked rather than by 
any logical association between the group names.

HTH,
Gary

-- 
Gary Johnson                 | Agilent Technologies
[EMAIL PROTECTED]     | Wireless Division
                             | Spokane, Washington, USA
" Vim syntax file
" Language:     Build Manager output
" Maintainer:   Gary Johnson <[EMAIL PROTECTED]>
" Last Change:  2004-10-04 13:05:53

" Quit when a syntax file was already loaded.
if exists("b:current_syntax")
  finish
endif

syn match bldmgrComment         /#.*/
syn match bldmgrCmd             /^CMD: .*/
syn match bldmgrWarning         /.*\<warning\>.*\c/
syn match bldmgrError           /.*\<Error\>.*/
syn match bldmgrComplete        /^=== Build Complete 
===\n\_.\{-}\(\(\_^\s*$\)\|\%$\)/
                                        " Terminated by a blank line or
                                        " end of file.

" Define the default highlighting.
"
hi def link bldmgrComment       Comment
hi def link bldmgrCmd           MoreMsg
hi def link bldmgrWarning       Directory
hi def link bldmgrError         WarningMsg
hi def link bldmgrComplete      Title

let b:current_syntax = "bldmgr"

" vim: ts=8 sw=2

Reply via email to