" Vim syntax file " Language: Tcl " Maintainer: Andy Goth " (previously Dean Copsey ) " (previously Matt Neumann ) " (previously Allan Kelly ) " Original: Robin Becker " Last Change: 2009 Jan 30 " Wishlist: " - Highlight extra characters after close quote (using nextgroup?) " - Highlight opening and closing braces (not possible in Vim?) " - Highlight extra characters after closing brace (not possible in Vim?) " - Highlight $, {, }, (, and ) differently for variable substitution " - Highlight variable array index (needs @tclCommandSubList inside parens) " - Highlight dot in numbers ending in a dot (\> doesn't work in this case) " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear elseif exists("b:current_syntax") finish endif " Command substitution syn region tclCommandSub matchgroup=tclCmdSubRegion start="\(\(^\|[^\\]\)\(\\\\\)*\)\@<=\[" end="\(\(^\|[^\\]\)\(\\\\\)*\)\@<=\]" contains=@tclCommandSubList " :: signifies a namespace, whereas single : terminates the variable name syn match tclVarRef "$\(::\|[a-zA-Z0-9_]\)\+" contains=tclNamespace " ${...} may contain any character except '}' syn match tclVarRef "${[^}]*}" contains=tclNamespace " Highlight special characters (those which have a backslash) differently syn match tclSpecial "\\\d\d\d\=\|\\." " Match at start of line syn region tclString matchgroup=tclStringRegion start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=@tclStringList " Match at start of word syn region tclString matchgroup=tclStringRegion start=+\s\+"+ms=s+1 skip=+\\\\\|\\"+ end=+"+ contains=@tclStringList syn match tclLineContinue "\\$" syn match tclExpand "{\*}" syn match tclNamespace "::" syn keyword tclTodo TODO XXX FIXME NOTE BUG contained " Note: A backslash followed by whitespace followed by end of line will be " highlighted as a tclSpecial, not a tclLineContinue. This is correct because " Tcl doesn't treat it as a line continuation but rather as an extra word " containing a single whitespace character. This is why these two are " highlighted with different colors. " Decimal or octal integer syn match tclNumber "-\?\<\d\+\>" " Hex integer syn match tclNumber "-\?0[xX][0-9a-fA-F]\+\>" " Real number, with dot, optional exponent syn match tclNumber "-\?\<\d\+\.\d*\([eE][-+]\?\d\+\)\?\>" " Real number, starting with a dot, optional exponent syn match tclNumber "-\?\.\d\+\([eE][-+]\?\d\+\)\?\>" " Real number, without dot, with exponent syn match tclNumber "-\?\<\d\+[eE][-+]\?\d\+\>" " Match at start of line syn region tclComment start="^\s*\#" skip="\\$" end="$" contains=tclTodo " Match at start of command syn region tclComment start=";\s*\#"hs=s+1 skip="\\$" end="$" contains=tclTodo syn cluster tclStringList contains=tclCommandSub,tclVarRef,tclSpecial,tclLineContinue,tclNamespace syn cluster tclCommandSubList contains=@tclStringList,tclString,tclNumber,tclComment,tclExpand " Define the default highlighting. " For version 5.7 and earlier: only when not done already " For version 5.8 and later: only when an item doesn't have highlighting yet if version >= 508 || !exists("did_tcl_syntax_inits") if version < 508 let did_tcl_syntax_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif HiLink tclCommandSub Normal HiLink tclCmdSubRegion Statement HiLink tclNumber Number HiLink tclString String HiLink tclComment Comment HiLink tclSpecial Special HiLink tclTodo Todo HiLink tclExpand Special HiLink tclLineContinue PreProc HiLink tclString String HiLink tclStringRegion PreProc HiLink tclNamespace Special HiLink tclVarRef Type " was Identifier, but this is more visible delcommand HiLink endif let b:current_syntax = "tcl" " vim: ts=8