Adding keywords if a line starts with a certain word

2006-06-26 Thread Robert Hicks
I would like to add additional keywords if the first word or first 4 
characters of the statement is snit.


snit::type dog {
method {tail wag} {} {return Wag, wag}
method {tail droop} {} {return Droop, droop}
}

Since snit is there then I would like to added method as a keyword.

Robert



Re: Adding keywords if a line starts with a certain word

2006-06-26 Thread Tim Chase
I would like to add additional keywords if the first word or first 4 
characters of the statement is snit.


snit::type dog {
 method {tail wag} {} {return Wag, wag}
 method {tail droop} {} {return Droop, droop}
}

Since snit is there then I would like to added method as a keyword.


Your language here uses some definition/syntax with which I'm not 
familiar (might be smalltalk?).  I'm not sure what you mean that 
you would like method added as a keyword.  Do you want to add a 
third method line?  Having some before and after descriptions 
of the code might help clarify matters.


If you just want to perform actions on snits, and assuming you 
use consistent indentation such that snit:: is always at the 
beginning of the line, and its closing } is also always at the 
beginning of the line, you can do things like



:g/^snit::/.+,/^}/-s/regexp/replacement/g

or you can add fixed text lines like

:g/^snit/put ='method {tail falloff} {} {return Ouch, ouch!}'

Or you might be talking about Vim's syntax-highlighting, in which 
case:


do you want to just highlight snit?

:match Keyword /^snit/

Or do you want to dynamically create syntax-highlighting 
definitions based on things found in your method defintions?


With a bit of clarification, there's likely a fairly easy solution.

-tim







Re: Adding keywords if a line starts with a certain word

2006-06-26 Thread Robert Hicks

Tim Chase wrote:
I would like to add additional keywords if the first word or first 4 
characters of the statement is snit.


snit::type dog {
 method {tail wag} {} {return Wag, wag}
 method {tail droop} {} {return Droop, droop}
}

Since snit is there then I would like to added method as a keyword.


Your language here uses some definition/syntax with which I'm not 
familiar (might be smalltalk?).  I'm not sure what you mean that you 
would like method added as a keyword.  Do you want to add a third 
method line?  Having some before and after descriptions of the code 
might help clarify matters.


Snit is an OO extension to Tcl.



If you just want to perform actions on snits, and assuming you use 
consistent indentation such that snit:: is always at the beginning of 
the line, and its closing } is also always at the beginning of the 
line, you can do things like


What I am looking for is if snit is the first word then method will 
be added as a keyword and colored.


snip


Or do you want to dynamically create syntax-highlighting definitions 
based on things found in your method defintions?




Yes, I believe that is correct. Actually it might be easier to find if 
snit is anywhere in the file at the beginning of the line (it will 
always be at the beginning) and then adding some extra keywords in to be 
colored.



With a bit of clarification, there's likely a fairly easy solution.



Did I clarify anything? I hope so.

Robert