annotate runtime/syntax/dosbatch.vim @ 1491:a135270b7549 v7.1.206

updated for version 7.1-206
author vimboss
date Sat, 05 Jan 2008 12:59:22 +0000
parents 3fc0f57ecb91
children 53938adac247
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: MSDOS batch file (with NT command extensions)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Mike Williams <mrw@eandem.co.uk>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " Filenames: *.bat
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Last Change: 16th March 2004
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Web Page: http://www.eandem.co.uk/mrw/vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " Options Flags:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 " dosbatch_cmdextversion - 1 = Windows NT, 2 = Windows 2000 [default]
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " Set default highlighting to Win2k
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if !exists("dosbatch_cmdextversion")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 let dosbatch_cmdextversion = 2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 " DOS bat files are case insensitive but case preserving!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 syn keyword dosbatchTodo contained TODO
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " Dosbat keywords
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 syn keyword dosbatchStatement goto call exit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 syn keyword dosbatchConditional if else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 syn keyword dosbatchRepeat for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " Some operators - first lot are case sensitive!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 syn case match
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 syn keyword dosbatchOperator EQU NEQ LSS LEQ GTR GEQ
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 syn match dosbatchOperator "\s[-+\*/%]\s"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 syn match dosbatchOperator "="
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 syn match dosbatchOperator "[-+\*/%]="
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 syn match dosbatchOperator "\s\(&\||\|^\|<<\|>>\)=\=\s"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 syn match dosbatchIfOperator "if\s\+\(\(not\)\=\s\+\)\=\(exist\|defined\|errorlevel\|cmdextversion\)\="lc=2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " String - using "'s is a convenience rather than a requirement outside of FOR
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 syn match dosbatchString "\"[^"]*\"" contains=dosbatchVariable,dosBatchArgument,@dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 syn match dosbatchString "\<echo[^)>|]*"lc=4 contains=dosbatchVariable,dosbatchArgument,@dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 syn match dosbatchEchoOperator "\<echo\s\+\(on\|off\)\s*$"lc=4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 " For embedded commands
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 syn match dosbatchCmd "(\s*'[^']*'"lc=1 contains=dosbatchString,dosbatchVariable,dosBatchArgument,@dosbatchNumber,dosbatchImplicit,dosbatchStatement,dosbatchConditional,dosbatchRepeat,dosbatchOperator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 " Numbers - surround with ws to not include in dir and filenames
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 syn match dosbatchInteger "[[:space:]=(/:]\d\+"lc=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 syn match dosbatchHex "[[:space:]=(/:]0x\x\+"lc=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 syn match dosbatchBinary "[[:space:]=(/:]0b[01]\+"lc=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 syn match dosbatchOctal "[[:space:]=(/:]0\o\+"lc=1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 syn cluster dosbatchNumber contains=dosbatchInteger,dosbatchHex,dosbatchBinary,dosbatchOctal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " Command line switches
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 syn match dosbatchSwitch "/\(\a\+\|?\)"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Various special escaped char formats
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 syn match dosbatchSpecialChar "\^[&|()<>^]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 syn match dosbatchSpecialChar "\$[a-hl-npqstv_$+]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 syn match dosbatchSpecialChar "%%"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " Environment variables
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 syn match dosbatchIdentifier contained "\s\h\w*\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 syn match dosbatchVariable "%\h\w*%"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 syn match dosbatchVariable "%\h\w*:\*\=[^=]*=[^%]*%"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 syn match dosbatchVariable "%\h\w*:\~\d\+,\d\+%" contains=dosbatchInteger
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 syn match dosbatchVariable "!\h\w*!"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 syn match dosbatchVariable "!\h\w*:\*\=[^=]*=[^%]*!"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 syn match dosbatchVariable "!\h\w*:\~\d\+,\d\+!" contains=dosbatchInteger
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 syn match dosbatchSet "\s\h\w*[+-]\==\{-1}" contains=dosbatchIdentifier,dosbatchOperator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " Args to bat files and for loops, etc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 syn match dosbatchArgument "%\(\d\|\*\)"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 syn match dosbatchArgument "%%[a-z]\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if dosbatch_cmdextversion == 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 syn match dosbatchArgument "%\~[fdpnxs]\+\(\($PATH:\)\=[a-z]\|\d\)\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 syn match dosbatchArgument "%\~[fdpnxsatz]\+\(\($PATH:\)\=[a-z]\|\d\)\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 " Line labels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 syn match dosbatchLabel "^\s*:\s*\h\w*\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 syn match dosbatchLabel "\<\(goto\|call\)\s\+:\h\w*\>"lc=4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 syn match dosbatchLabel "\<goto\s\+\h\w*\>"lc=4
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 syn match dosbatchLabel ":\h\w*\>"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 " Comments - usual rem but also two colons as first non-space is an idiom
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 syn match dosbatchComment "^rem\($\|\s.*$\)"lc=3 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 syn match dosbatchComment "\srem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 syn match dosbatchComment "\s*:\s*:.*$" contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 " Comments in ()'s - still to handle spaces before rem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 syn match dosbatchComment "(rem[^)]*"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 syn keyword dosbatchImplicit append assoc at attrib break cacls cd chcp chdir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 syn keyword dosbatchImplicit chkdsk chkntfs cls cmd color comp compact convert copy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 syn keyword dosbatchImplicit date del dir diskcomp diskcopy doskey echo endlocal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 syn keyword dosbatchImplicit erase fc find findstr format ftype
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 syn keyword dosbatchImplicit graftabl help keyb label md mkdir mode more move
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 syn keyword dosbatchImplicit path pause popd print prompt pushd rd recover rem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 syn keyword dosbatchImplicit ren rename replace restore rmdir set setlocal shift
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 syn keyword dosbatchImplicit sort start subst time title tree type ver verify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 syn keyword dosbatchImplicit vol xcopy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 " For version 5.8 and later: only when an item doesn't have highlighting yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 if version >= 508 || !exists("did_dosbatch_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 let did_dosbatch_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 HiLink dosbatchTodo Todo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 HiLink dosbatchStatement Statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 HiLink dosbatchCommands dosbatchStatement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 HiLink dosbatchLabel Label
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 HiLink dosbatchConditional Conditional
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 HiLink dosbatchRepeat Repeat
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 HiLink dosbatchOperator Operator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 HiLink dosbatchEchoOperator dosbatchOperator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 HiLink dosbatchIfOperator dosbatchOperator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 HiLink dosbatchArgument Identifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 HiLink dosbatchIdentifier Identifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 HiLink dosbatchVariable dosbatchIdentifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 HiLink dosbatchSpecialChar SpecialChar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 HiLink dosbatchString String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 HiLink dosbatchNumber Number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 HiLink dosbatchInteger dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 HiLink dosbatchHex dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 HiLink dosbatchBinary dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 HiLink dosbatchOctal dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 HiLink dosbatchComment Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147 HiLink dosbatchImplicit Function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 HiLink dosbatchSwitch Special
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 HiLink dosbatchCmd PreProc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 let b:current_syntax = "dosbatch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 " vim: ts=8