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 "snit"s, 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