Tim Chase wrote:
syn match tclV "ttk\(\(::\)\?\([[:alnum:]_.]*::\)*\)\a[a-zA-Z0-9_.]*"

I only want this to work "ttk" at the start. I know that ^ means the start but I am not sure how to add that (I did try just adding it) to make the regex start with "ttk".

Just put it at the beginning:

    "^ttk..."

just as you would use the dollar-sign at the end to anchor something to the end of the line:

    "regexp$"

-tim

Similarly, to allow it as long as it is the first non-whitespace characters, add "zero or more whitespace" between ^ and ttk :

        "^\s*ttk..."

See ":help pattern.txt" for more info on Vim regular expressions (and dont forget the .txt extension, or you'll be brought to a formal syntax definition instead of to the table of contents of the helpfile).

Note that $^ in the middle of a pattern usually matches dollar followed by caret, not a linebreak. ( \n matches a linebreak IIUC; but in substitute you must use :s/\n/\r/ to replace a linebreak by itself.)


Best regards,
Tony.

Reply via email to