" Vim syntax file" Language: 4Dos batch file" Maintainer: John Leo Spetz <jls11@po.cwru.edu>" Last Change: 2001 May 09"//Issues to resolve:"//- Boolean operators surrounded by period are recognized but the"// periods are not highlighted. The only way to do that would"// be separate synmatches for each possibility otherwise a more"// general \.\i\+\. will highlight anything delimited by dots."//- After unary operators like "defined" can assume token type."// Should there be more of these?" For version 5.x: Clear all syntax items" For version 6.x: Quit when a syntax file was already loadedif version < 600 syntax clearelseif exists("b:current_syntax") finishendifsyn case ignoresyn keyword btmStatement call offsyn keyword btmConditional if iff endiff then else elseiff not errorlevelsyn keyword btmConditional gt lt eq ne ge lesyn match btmConditional transparent "\.\i\+\." contains=btmDotBoolOpsyn keyword btmDotBoolOp contained and or xorsyn match btmConditional "=="syn match btmConditional "!="syn keyword btmConditional defined errorlevel exist isaliassyn keyword btmConditional isdir direxist isinternal islabelsyn keyword btmRepeat for in do enddosyn keyword btmTodo contained TODO" Stringsyn cluster btmVars contains=btmVariable,btmArgument,btmBIFMatchsyn region btmString start=+"+ end=+"+ contains=@btmVarssyn match btmNumber "\<\d\+\>""syn match btmIdentifier "\<\h\w*\>"" If you don't like tabs"syn match btmShowTab "\t""syn match btmShowTabc "\t""syn match btmComment "^\ *rem.*$" contains=btmTodo,btmShowTabc" Some people use this as a comment line" In fact this is a Label"syn match btmComment "^\ *:\ \+.*$" contains=btmTodosyn match btmComment "^\ *rem.*$" contains=btmTodosyn match btmComment "^\ *::.*$" contains=btmTodosyn match btmLabelMark "^\ *:[0-9a-zA-Z_\-]\+\>"syn match btmLabelMark "goto [0-9a-zA-Z_\-]\+\>"lc=5syn match btmLabelMark "gosub [0-9a-zA-Z_\-]\+\>"lc=6" syn match btmCmdDivider ">[>&][>&]\="syn match btmCmdDivider ">[>&]*"syn match btmCmdDivider ">>&>"syn match btmCmdDivider "|&\="syn match btmCmdDivider "%+"syn match btmCmdDivider "\^"syn region btmEcho start="echo" skip="echo" matchgroup=btmCmdDivider end="%+" end="$" end="|&\=" end="\^" end=">[>&]*" contains=@btmEchos onelinesyn cluster btmEchos contains=@btmVars,btmEchoCommand,btmEchoParamsyn keyword btmEchoCommand contained echo echoerr echos echoserrsyn keyword btmEchoParam contained on off" this is also a valid Label. I don't use it."syn match btmLabelMark "^\ *:\ \+[0-9a-zA-Z_\-]\+\>"" //Environment variable can be expanded using notation %var in 4DOSsyn match btmVariable "%[0-9a-z_\-]\+" contains=@btmSpecialVars" //Environment variable can be expanded using notation %var%syn match btmVariable "%[0-9a-z_\-]*%" contains=@btmSpecialVars" //The following are special variable in 4DOSsyn match btmVariable "%[=#]" contains=@btmSpecialVarssyn match btmVariable "%??\=" contains=@btmSpecialVars" //Environment variable can be expanded using notation %[var] in 4DOSsyn match btmVariable "%\[[0-9a-z_\-]*\]"" //After some keywords next word should be an environment variablesyn match btmVariable "defined\s\i\+"lc=8syn match btmVariable "set\s\i\+"lc=4" //Parameters to batchfiles take the format %<digit>syn match btmArgument "%\d\>"" //4DOS allows format %<digit>& meaning batchfile parameters digit and upsyn match btmArgument "%\d\>&"" //Variable used by FOR loops sometimes use %%<letter> in batchfilessyn match btmArgument "%%\a\>"" //Show 4DOS built-in functions speciallysyn match btmBIFMatch "%@\w\+\["he=e-1 contains=btmBuiltInFuncsyn keyword btmBuiltInFunc contained alias ascii attrib cdromsyn keyword btmBuiltInFunc contained char clip comma convertsyn keyword btmBuiltInFunc contained date day dec descriptsyn keyword btmBuiltInFunc contained device diskfree disktotalsyn keyword btmBuiltInFunc contained diskused dosmem dow dowisyn keyword btmBuiltInFunc contained doy ems eval exec execstrsyn keyword btmBuiltInFunc contained expand ext extendedsyn keyword btmBuiltInFunc contained fileage fileclose filedatesyn keyword btmBuiltInFunc contained filename fileopen filereadsyn keyword btmBuiltInFunc contained files fileseek fileseeklsyn keyword btmBuiltInFunc contained filesize filetime filewritesyn keyword btmBuiltInFunc contained filewriteb findclosesyn keyword btmBuiltInFunc contained findfirst findnext formatsyn keyword btmBuiltInFunc contained full if inc index insertsyn keyword btmBuiltInFunc contained instr int label left lensyn keyword btmBuiltInFunc contained lfn line lines lower lptsyn keyword btmBuiltInFunc contained makeage makedate maketimesyn keyword btmBuiltInFunc contained master month name numericsyn keyword btmBuiltInFunc contained path random readscr readysyn keyword btmBuiltInFunc contained remote removable repeatsyn keyword btmBuiltInFunc contained replace right searchsyn keyword btmBuiltInFunc contained select sfn strip substrsyn keyword btmBuiltInFunc contained time timer trim truenamesyn keyword btmBuiltInFunc contained unique upper wild wordsyn keyword btmBuiltInFunc contained words xms yearsyn cluster btmSpecialVars contains=btmBuiltInVar,btmSpecialVar" //Show specialized variables specially" syn match btmSpecialVar contained "+"syn match btmSpecialVar contained "="syn match btmSpecialVar contained "#"syn match btmSpecialVar contained "??\="syn keyword btmSpecialVar contained cmdline colordir comspecsyn keyword btmSpecialVar contained copycmd dircmd temp temp4dossyn keyword btmSpecialVar contained filecompletion path prompt" //Show 4DOS built-in variables specially speciallysyn keyword btmBuiltInVar contained _4ver _alias _ansisyn keyword btmBuiltInVar contained _apbatt _aplife _apmac _batchsyn keyword btmBuiltInVar contained _batchline _batchname _bgsyn keyword btmBuiltInVar contained _boot _ci _cmdproc _cosyn keyword btmBuiltInVar contained _codepage _column _columnssyn keyword btmBuiltInVar contained _country _cpu _cwd _cwds _cwpsyn keyword btmBuiltInVar contained _cwps _date _day _disk _dnamesyn keyword btmBuiltInVar contained _dos _dosver _dow _dowi _doysyn keyword btmBuiltInVar contained _dpmi _dv _env _fg _hlogfilesyn keyword btmBuiltInVar contained _hour _kbhit _kstack _lastdisksyn keyword btmBuiltInVar contained _logfile _minute _monitorsyn keyword btmBuiltInVar contained _month _mouse _ndp _row _rowssyn keyword btmBuiltInVar contained _second _shell _swappingsyn keyword btmBuiltInVar contained _syserr _time _transientsyn keyword btmBuiltInVar contained _video _win _wintitle _year" //Commands in 4DOS and/or DOSsyn match btmCommand "\s?"syn match btmCommand "^?"syn keyword btmCommand alias append assign attribsyn keyword btmCommand backup beep break cancel casesyn keyword btmCommand cd cdd cdpath chcp chdirsyn keyword btmCommand chkdsk cls color comp copysyn keyword btmCommand ctty date debug default defragsyn keyword btmCommand del delay describe dirsyn keyword btmCommand dirhistory dirs diskcompsyn keyword btmCommand diskcopy doskey dosshellsyn keyword btmCommand drawbox drawhline drawvline"syn keyword btmCommand echo echoerr echos echoserrsyn keyword btmCommand edit edlin emm386 endlocalsyn keyword btmCommand endswitch erase eset exceptsyn keyword btmCommand exe2bin exit expand fastopensyn keyword btmCommand fc fdisk ffind find formatsyn keyword btmCommand free global gosub gotosyn keyword btmCommand graftabl graphics help historysyn keyword btmCommand inkey input join keyb keybdsyn keyword btmCommand keystack label lh list loadbtmsyn keyword btmCommand loadhigh lock log md memsyn keyword btmCommand memory mirror mkdir mode moresyn keyword btmCommand move nlsfunc on option pathsyn keyword btmCommand pause popd print prompt pushdsyn keyword btmCommand quit rd reboot recover rensyn keyword btmCommand rename replace restore returnsyn keyword btmCommand rmdir scandisk screen scrputsyn keyword btmCommand select set setdos setlocalsyn keyword btmCommand setver share shift sort substsyn keyword btmCommand swapping switch sys tee textsyn keyword btmCommand time timer touch tree truenamesyn keyword btmCommand type unalias undelete unformatsyn keyword btmCommand unlock unset ver verify volsyn keyword btmCommand vscrput y" 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 yetif version >= 508 || !exists("did_btm_syntax_inits") if version < 508 let did_btm_syntax_inits = 1 command -nargs=+ HiLink hi link <args> else command -nargs=+ HiLink hi def link <args> endif HiLink btmLabel Special HiLink btmLabelMark Special HiLink btmCmdDivider Special HiLink btmConditional btmStatement HiLink btmDotBoolOp btmStatement HiLink btmRepeat btmStatement HiLink btmEchoCommand btmStatement HiLink btmEchoParam btmStatement HiLink btmStatement Statement HiLink btmTodo Todo HiLink btmString String HiLink btmNumber Number HiLink btmComment Comment HiLink btmArgument Identifier HiLink btmVariable Identifier HiLink btmEcho String HiLink btmBIFMatch btmStatement HiLink btmBuiltInFunc btmStatement HiLink btmBuiltInVar btmStatement HiLink btmSpecialVar btmStatement HiLink btmCommand btmStatement "optional highlighting "HiLink btmShowTab Error "HiLink btmShowTabc Error "hiLink btmIdentifier Identifier delcommand HiLinkendiflet b:current_syntax = "btm"" vim: ts=8
" Vim syntax file
" Language: 4Dos batch file
" Maintainer: John Leo Spetz <jls11@po.cwru.edu>
" Last Change: 2001 May 09
"//Issues to resolve:
"//- Boolean operators surrounded by period are recognized but the
"// periods are not highlighted. The only way to do that would
"// be separate synmatches for each possibility otherwise a more
"// general \.\i\+\. will highlight anything delimited by dots.
"//- After unary operators like "defined" can assume token type.
"// Should there be more of these?
" 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
syn case ignore
syn keyword btmStatement call off
syn keyword btmConditional if iff endiff then else elseiff not errorlevel
syn keyword btmConditional gt lt eq ne ge le
syn match btmConditional transparent "\.\i\+\." contains=btmDotBoolOp
syn keyword btmDotBoolOp contained and or xor
syn match btmConditional "=="
syn match btmConditional "!="
syn keyword btmConditional defined errorlevel exist isalias
syn keyword btmConditional isdir direxist isinternal islabel
syn keyword btmRepeat for in do enddo
syn keyword btmTodo contained TODO
" String
syn cluster btmVars contains=btmVariable,btmArgument,btmBIFMatch
syn region btmString start=+"+ end=+"+ contains=@btmVars
syn match btmNumber "\<\d\+\>"
"syn match btmIdentifier "\<\h\w*\>"
" If you don't like tabs
"syn match btmShowTab "\t"
"syn match btmShowTabc "\t"
"syn match btmComment "^\ *rem.*$" contains=btmTodo,btmShowTabc
" Some people use this as a comment line
" In fact this is a Label
"syn match btmComment "^\ *:\ \+.*$" contains=btmTodo
syn match btmComment "^\ *rem.*$" contains=btmTodo
syn match btmComment "^\ *::.*$" contains=btmTodo
syn match btmLabelMark "^\ *:[0-9a-zA-Z_\-]\+\>"
syn match btmLabelMark "goto [0-9a-zA-Z_\-]\+\>"lc=5
syn match btmLabelMark "gosub [0-9a-zA-Z_\-]\+\>"lc=6
" syn match btmCmdDivider ">[>&][>&]\="
syn match btmCmdDivider ">[>&]*"
syn match btmCmdDivider ">>&>"
syn match btmCmdDivider "|&\="
syn match btmCmdDivider "%+"
syn match btmCmdDivider "\^"
syn region btmEcho start="echo" skip="echo" matchgroup=btmCmdDivider end="%+" end="$" end="|&\=" end="\^" end=">[>&]*" contains=@btmEchos oneline
syn cluster btmEchos contains=@btmVars,btmEchoCommand,btmEchoParam
syn keyword btmEchoCommand contained echo echoerr echos echoserr
syn keyword btmEchoParam contained on off
" this is also a valid Label. I don't use it.
"syn match btmLabelMark "^\ *:\ \+[0-9a-zA-Z_\-]\+\>"
" //Environment variable can be expanded using notation %var in 4DOS
syn match btmVariable "%[0-9a-z_\-]\+" contains=@btmSpecialVars
" //Environment variable can be expanded using notation %var%
syn match btmVariable "%[0-9a-z_\-]*%" contains=@btmSpecialVars
" //The following are special variable in 4DOS
syn match btmVariable "%[=#]" contains=@btmSpecialVars
syn match btmVariable "%??\=" contains=@btmSpecialVars
" //Environment variable can be expanded using notation %[var] in 4DOS
syn match btmVariable "%\[[0-9a-z_\-]*\]"
" //After some keywords next word should be an environment variable
syn match btmVariable "defined\s\i\+"lc=8
syn match btmVariable "set\s\i\+"lc=4
" //Parameters to batchfiles take the format %<digit>
syn match btmArgument "%\d\>"
" //4DOS allows format %<digit>& meaning batchfile parameters digit and up
syn match btmArgument "%\d\>&"
" //Variable used by FOR loops sometimes use %%<letter> in batchfiles
syn match btmArgument "%%\a\>"
" //Show 4DOS built-in functions specially
syn match btmBIFMatch "%@\w\+\["he=e-1 contains=btmBuiltInFunc
syn keyword btmBuiltInFunc contained alias ascii attrib cdrom
syn keyword btmBuiltInFunc contained char clip comma convert
syn keyword btmBuiltInFunc contained date day dec descript
syn keyword btmBuiltInFunc contained device diskfree disktotal
syn keyword btmBuiltInFunc contained diskused dosmem dow dowi
syn keyword btmBuiltInFunc contained doy ems eval exec execstr
syn keyword btmBuiltInFunc contained expand ext extended
syn keyword btmBuiltInFunc contained fileage fileclose filedate
syn keyword btmBuiltInFunc contained filename fileopen fileread
syn keyword btmBuiltInFunc contained files fileseek fileseekl
syn keyword btmBuiltInFunc contained filesize filetime filewrite
syn keyword btmBuiltInFunc contained filewriteb findclose
syn keyword btmBuiltInFunc contained findfirst findnext format
syn keyword btmBuiltInFunc contained full if inc index insert
syn keyword btmBuiltInFunc contained instr int label left len
syn keyword btmBuiltInFunc contained lfn line lines lower lpt
syn keyword btmBuiltInFunc contained makeage makedate maketime
syn keyword btmBuiltInFunc contained master month name numeric
syn keyword btmBuiltInFunc contained path random readscr ready
syn keyword btmBuiltInFunc contained remote removable repeat
syn keyword btmBuiltInFunc contained replace right search
syn keyword btmBuiltInFunc contained select sfn strip substr
syn keyword btmBuiltInFunc contained time timer trim truename
syn keyword btmBuiltInFunc contained unique upper wild word
syn keyword btmBuiltInFunc contained words xms year
syn cluster btmSpecialVars contains=btmBuiltInVar,btmSpecialVar
" //Show specialized variables specially
" syn match btmSpecialVar contained "+"
syn match btmSpecialVar contained "="
syn match btmSpecialVar contained "#"
syn match btmSpecialVar contained "??\="
syn keyword btmSpecialVar contained cmdline colordir comspec
syn keyword btmSpecialVar contained copycmd dircmd temp temp4dos
syn keyword btmSpecialVar contained filecompletion path prompt
" //Show 4DOS built-in variables specially specially
syn keyword btmBuiltInVar contained _4ver _alias _ansi
syn keyword btmBuiltInVar contained _apbatt _aplife _apmac _batch
syn keyword btmBuiltInVar contained _batchline _batchname _bg
syn keyword btmBuiltInVar contained _boot _ci _cmdproc _co
syn keyword btmBuiltInVar contained _codepage _column _columns
syn keyword btmBuiltInVar contained _country _cpu _cwd _cwds _cwp
syn keyword btmBuiltInVar contained _cwps _date _day _disk _dname
syn keyword btmBuiltInVar contained _dos _dosver _dow _dowi _doy
syn keyword btmBuiltInVar contained _dpmi _dv _env _fg _hlogfile
syn keyword btmBuiltInVar contained _hour _kbhit _kstack _lastdisk
syn keyword btmBuiltInVar contained _logfile _minute _monitor
syn keyword btmBuiltInVar contained _month _mouse _ndp _row _rows
syn keyword btmBuiltInVar contained _second _shell _swapping
syn keyword btmBuiltInVar contained _syserr _time _transient
syn keyword btmBuiltInVar contained _video _win _wintitle _year
" //Commands in 4DOS and/or DOS
syn match btmCommand "\s?"
syn match btmCommand "^?"
syn keyword btmCommand alias append assign attrib
syn keyword btmCommand backup beep break cancel case
syn keyword btmCommand cd cdd cdpath chcp chdir
syn keyword btmCommand chkdsk cls color comp copy
syn keyword btmCommand ctty date debug default defrag
syn keyword btmCommand del delay describe dir
syn keyword btmCommand dirhistory dirs diskcomp
syn keyword btmCommand diskcopy doskey dosshell
syn keyword btmCommand drawbox drawhline drawvline
"syn keyword btmCommand echo echoerr echos echoserr
syn keyword btmCommand edit edlin emm386 endlocal
syn keyword btmCommand endswitch erase eset except
syn keyword btmCommand exe2bin exit expand fastopen
syn keyword btmCommand fc fdisk ffind find format
syn keyword btmCommand free global gosub goto
syn keyword btmCommand graftabl graphics help history
syn keyword btmCommand inkey input join keyb keybd
syn keyword btmCommand keystack label lh list loadbtm
syn keyword btmCommand loadhigh lock log md mem
syn keyword btmCommand memory mirror mkdir mode more
syn keyword btmCommand move nlsfunc on option path
syn keyword btmCommand pause popd print prompt pushd
syn keyword btmCommand quit rd reboot recover ren
syn keyword btmCommand rename replace restore return
syn keyword btmCommand rmdir scandisk screen scrput
syn keyword btmCommand select set setdos setlocal
syn keyword btmCommand setver share shift sort subst
syn keyword btmCommand swapping switch sys tee text
syn keyword btmCommand time timer touch tree truename
syn keyword btmCommand type unalias undelete unformat
syn keyword btmCommand unlock unset ver verify vol
syn keyword btmCommand vscrput y
" 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_btm_syntax_inits")
if version < 508
let did_btm_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink btmLabel Special
HiLink btmLabelMark Special
HiLink btmCmdDivider Special
HiLink btmConditional btmStatement
HiLink btmDotBoolOp btmStatement
HiLink btmRepeat btmStatement
HiLink btmEchoCommand btmStatement
HiLink btmEchoParam btmStatement
HiLink btmStatement Statement
HiLink btmTodo Todo
HiLink btmString String
HiLink btmNumber Number
HiLink btmComment Comment
HiLink btmArgument Identifier
HiLink btmVariable Identifier
HiLink btmEcho String
HiLink btmBIFMatch btmStatement
HiLink btmBuiltInFunc btmStatement
HiLink btmBuiltInVar btmStatement
HiLink btmSpecialVar btmStatement
HiLink btmCommand btmStatement
"optional highlighting
"HiLink btmShowTab Error
"HiLink btmShowTabc Error
"hiLink btmIdentifier Identifier
delcommand HiLink
endif
let b:current_syntax = "btm"
" vim: ts=8