2 " Language: Windows Registry export with regedit (*.reg)
3 " Maintainer: Dominique Stéphan (dominique@mggen.com)
4 " URL: http://www.mggen.com/vim/syntax/registry.zip
5 " Last change: 2004 Apr 23
7 " clear any unwanted syntax defs
8 " For version 5.x: Clear all syntax items
9 " For version 6.x: Quit when a syntax file was already loaded
12 elseif exists("b:current_syntax")
19 " Head of regedit .reg files, it's REGEDIT4 on Win9#/NT
20 syn match registryHead "^REGEDIT[0-9]*$"
23 syn match registryComment "^;.*$"
25 " Registry Key constant
26 syn keyword registryHKEY HKEY_LOCAL_MACHINE HKEY_CLASSES_ROOT HKEY_CURRENT_USER
27 syn keyword registryHKEY HKEY_USERS HKEY_CURRENT_CONFIG HKEY_DYN_DATA
28 " Registry Key shortcuts
29 syn keyword registryHKEY HKLM HKCR HKCU HKU HKCC HKDD
31 " Some values often found in the registry
32 " GUID (Global Unique IDentifier)
33 syn match registryGUID "{[0-9A-Fa-f]\{8}\-[0-9A-Fa-f]\{4}\-[0-9A-Fa-f]\{4}\-[0-9A-Fa-f]\{4}\-[0-9A-Fa-f]\{12}}" contains=registrySpecial
36 " syn match registryDisk "[a-zA-Z]:\\\\"
38 " Special and Separator characters
39 syn match registrySpecial "\\"
40 syn match registrySpecial "\\\\"
41 syn match registrySpecial "\\\""
42 syn match registrySpecial "\."
43 syn match registrySpecial ","
44 syn match registrySpecial "\/"
45 syn match registrySpecial ":"
46 syn match registrySpecial "-"
49 syn match registryString "\".*\"" contains=registryGUID,registrySpecial
52 syn region registryPath start="\[" end="\]" contains=registryHKEY,registryGUID,registrySpecial
55 " like preceding path but with a "-" at begin
56 syn region registryRemove start="\[\-" end="\]" contains=registryHKEY,registryGUID,registrySpecial
59 syn match registrySubKey "^\".*\"="
61 syn match registrySubKey "^\@="
66 " The format can be precised between () :
71 " 4 REG_DWORD, REG_DWORD_LITTLE_ENDIAN
72 " 5 REG_DWORD_BIG_ENDIAN
76 " 9 REG_FULL_RESOURCE_DESCRIPTOR
77 " 10 REG_RESOURCE_REQUIREMENTS_LIST
78 " The value can take several lines, if \ ends the line
79 " The limit to 999 matches is arbitrary, it avoids Vim crashing on a very long
80 " line of hex values that ends in a comma.
81 "syn match registryHex "hex\(([0-9]\{0,2})\)\=:\([0-9a-fA-F]\{2},\)\{0,999}\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial
82 syn match registryHex "hex\(([0-9]\{0,2})\)\=:\([0-9a-fA-F]\{2},\)*\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial
83 syn match registryHex "^\s*\([0-9a-fA-F]\{2},\)\{0,999}\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial
85 syn match registryDword "dword:[0-9a-fA-F]\{8}$" contains=registrySpecial
87 if version >= 508 || !exists("did_registry_syntax_inits")
89 let did_registry_syntax_inits = 1
90 command -nargs=+ HiLink hi link <args>
92 command -nargs=+ HiLink hi def link <args>
95 " The default methods for highlighting. Can be overridden later
96 HiLink registryComment Comment
97 HiLink registryHead Constant
98 HiLink registryHKEY Constant
99 HiLink registryPath Special
100 HiLink registryRemove PreProc
101 HiLink registryGUID Identifier
102 HiLink registrySpecial Special
103 HiLink registrySubKey Type
104 HiLink registryString String
105 HiLink registryHex Number
106 HiLink registryDword Number
112 let b:current_syntax = "registry"