annotate runtime/syntax/dosbatch.vim @ 3484:982f84487daf v7.3.506

updated for version 7.3.506 Problem: GTK gives an error when selecting a non-existent file. Solution: Add a handler to avoid the error. (Christian Brabandt)
author Bram Moolenaar <bram@vim.org>
date Wed, 25 Apr 2012 17:10:16 +0200
parents 7bc41231fbc7
children 43efa4f5a8ea
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
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
5 " Last Change: 6th September 2009
7
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
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
39 syn match dosbatchOperator "\s[-+\*/%!~]\s"
7
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
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
46 syn match dosbatchString "\"[^"]*\"" contains=dosbatchVariable,dosBatchArgument,dosbatchSpecialChar,@dosbatchNumber,@Spell
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
47 syn match dosbatchString "\<echo\([^)>|]\|\^\@<=[)>|]\)*"lc=4 contains=dosbatchVariable,dosbatchArgument,dosbatchSpecialChar,@dosbatchNumber,@Spell
7
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
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
54 syn match dosbatchInteger "[[:space:]=(/:,!~-]\d\+"lc=1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
55 syn match dosbatchHex "[[:space:]=(/:,!~-]0x\x\+"lc=1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
56 syn match dosbatchBinary "[[:space:]=(/:,!~-]0b[01]\+"lc=1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
57 syn match dosbatchOctal "[[:space:]=(/:,!~-]0\o\+"lc=1
7
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*:\*\=[^=]*=[^%]*%"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
72 syn match dosbatchVariable "%\h\w*:\~[-]\=\d\+\(,[-]\=\d\+\)\=%" contains=dosbatchInteger
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 syn match dosbatchVariable "!\h\w*!"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
74 syn match dosbatchVariable "!\h\w*:\*\=[^=]*=[^!]*!"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
75 syn match dosbatchVariable "!\h\w*:\~[-]\=\d\+\(,[-]\=\d\+\)\=!" contains=dosbatchInteger
7
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\|\*\)"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
80 syn match dosbatchArgument "%[a-z]\>"
7
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
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
94 syn match dosbatchComment "^rem\($\|\s.*$\)"lc=3 contains=dosbatchTodo,dosbatchSpecialChar,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
95 syn match dosbatchComment "^@rem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
96 syn match dosbatchComment "\srem\($\|\s.*$\)"lc=4 contains=dosbatchTodo,dosbatchSpecialChar,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1623
diff changeset
97 syn match dosbatchComment "\s@rem\($\|\s.*$\)"lc=5 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
98 syn match dosbatchComment "\s*:\s*:.*$" contains=dosbatchTodo,dosbatchSpecialChar,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 " Comments in ()'s - still to handle spaces before rem
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
101 syn match dosbatchComment "(rem\([^)]\|\^\@<=)\)*"lc=4 contains=dosbatchTodo,@dosbatchNumber,dosbatchVariable,dosbatchArgument,@Spell
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 syn keyword dosbatchImplicit append assoc at attrib break cacls cd chcp chdir
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 syn keyword dosbatchImplicit chkdsk chkntfs cls cmd color comp compact convert copy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 syn keyword dosbatchImplicit date del dir diskcomp diskcopy doskey echo endlocal
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 syn keyword dosbatchImplicit erase fc find findstr format ftype
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 syn keyword dosbatchImplicit graftabl help keyb label md mkdir mode more move
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 syn keyword dosbatchImplicit path pause popd print prompt pushd rd recover rem
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 syn keyword dosbatchImplicit ren rename replace restore rmdir set setlocal shift
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 syn keyword dosbatchImplicit sort start subst time title tree type ver verify
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 syn keyword dosbatchImplicit vol xcopy
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 " 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
116 if version >= 508 || !exists("did_dosbatch_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 let did_dosbatch_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 HiLink dosbatchTodo Todo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 HiLink dosbatchStatement Statement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 HiLink dosbatchCommands dosbatchStatement
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 HiLink dosbatchLabel Label
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 HiLink dosbatchConditional Conditional
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 HiLink dosbatchRepeat Repeat
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
132 HiLink dosbatchOperator Operator
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
133 HiLink dosbatchEchoOperator dosbatchOperator
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
134 HiLink dosbatchIfOperator dosbatchOperator
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 HiLink dosbatchArgument Identifier
1623
53938adac247 updated for version 7.2a
vimboss
parents: 7
diff changeset
137 HiLink dosbatchIdentifier Identifier
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 HiLink dosbatchVariable dosbatchIdentifier
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 HiLink dosbatchSpecialChar SpecialChar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 HiLink dosbatchString String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 HiLink dosbatchNumber Number
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 HiLink dosbatchInteger dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144 HiLink dosbatchHex dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 HiLink dosbatchBinary dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 HiLink dosbatchOctal dosbatchNumber
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 HiLink dosbatchComment Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149 HiLink dosbatchImplicit Function
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
151 HiLink dosbatchSwitch Special
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
152
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
153 HiLink dosbatchCmd PreProc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
154
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
155 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
156 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
157
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
158 let b:current_syntax = "dosbatch"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
159
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
160 " vim: ts=8