blob: 4524247a08fcdd772ac1eba127fbc063e13912dd [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: Windows Registry export with regedit (*.reg)
Bram Moolenaar32efaf62014-11-05 17:02:17 +01003" Maintainer: Dominique Stéphan (dominique@mggen.com)
4" URL: http://www.mggen.com/vim/syntax/registry.zip (doesn't work)
5" Last change: 2014 Oct 31
6" Included patch from Alexander A. Ulitin
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8" clear any unwanted syntax defs
9" For version 5.x: Clear all syntax items
10" For version 6.x: Quit when a syntax file was already loaded
11if version < 600
12 syntax clear
13elseif exists("b:current_syntax")
14 finish
15endif
16
17" shut case off
18syn case ignore
19
20" Head of regedit .reg files, it's REGEDIT4 on Win9#/NT
Bram Moolenaar32efaf62014-11-05 17:02:17 +010021syn match registryHead "^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$"
Bram Moolenaar071d4272004-06-13 20:20:40 +000022
23" Comment
24syn match registryComment "^;.*$"
25
26" Registry Key constant
27syn keyword registryHKEY HKEY_LOCAL_MACHINE HKEY_CLASSES_ROOT HKEY_CURRENT_USER
28syn keyword registryHKEY HKEY_USERS HKEY_CURRENT_CONFIG HKEY_DYN_DATA
29" Registry Key shortcuts
30syn keyword registryHKEY HKLM HKCR HKCU HKU HKCC HKDD
31
32" Some values often found in the registry
33" GUID (Global Unique IDentifier)
34syn 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
35
36" Disk
37" syn match registryDisk "[a-zA-Z]:\\\\"
38
39" Special and Separator characters
40syn match registrySpecial "\\"
41syn match registrySpecial "\\\\"
42syn match registrySpecial "\\\""
43syn match registrySpecial "\."
44syn match registrySpecial ","
45syn match registrySpecial "\/"
46syn match registrySpecial ":"
47syn match registrySpecial "-"
48
49" String
50syn match registryString "\".*\"" contains=registryGUID,registrySpecial
51
52" Path
53syn region registryPath start="\[" end="\]" contains=registryHKEY,registryGUID,registrySpecial
54
55" Path to remove
56" like preceding path but with a "-" at begin
57syn region registryRemove start="\[\-" end="\]" contains=registryHKEY,registryGUID,registrySpecial
58
59" Subkey
60syn match registrySubKey "^\".*\"="
61" Default value
Bram Moolenaar32efaf62014-11-05 17:02:17 +010062syn match registrySubKey "^@="
Bram Moolenaar071d4272004-06-13 20:20:40 +000063
64" Numbers
65
66" Hex or Binary
67" The format can be precised between () :
68" 0 REG_NONE
69" 1 REG_SZ
70" 2 REG_EXPAND_SZ
71" 3 REG_BINARY
72" 4 REG_DWORD, REG_DWORD_LITTLE_ENDIAN
73" 5 REG_DWORD_BIG_ENDIAN
74" 6 REG_LINK
75" 7 REG_MULTI_SZ
76" 8 REG_RESOURCE_LIST
77" 9 REG_FULL_RESOURCE_DESCRIPTOR
78" 10 REG_RESOURCE_REQUIREMENTS_LIST
79" The value can take several lines, if \ ends the line
80" The limit to 999 matches is arbitrary, it avoids Vim crashing on a very long
81" line of hex values that ends in a comma.
82"syn match registryHex "hex\(([0-9]\{0,2})\)\=:\([0-9a-fA-F]\{2},\)\{0,999}\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial
83syn match registryHex "hex\(([0-9]\{0,2})\)\=:\([0-9a-fA-F]\{2},\)*\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial
84syn match registryHex "^\s*\([0-9a-fA-F]\{2},\)\{0,999}\([0-9a-fA-F]\{2}\|\\\)$" contains=registrySpecial
85" Dword (32 bits)
86syn match registryDword "dword:[0-9a-fA-F]\{8}$" contains=registrySpecial
87
88if version >= 508 || !exists("did_registry_syntax_inits")
89 if version < 508
90 let did_registry_syntax_inits = 1
91 command -nargs=+ HiLink hi link <args>
92 else
93 command -nargs=+ HiLink hi def link <args>
94 endif
95
96" The default methods for highlighting. Can be overridden later
97 HiLink registryComment Comment
98 HiLink registryHead Constant
99 HiLink registryHKEY Constant
100 HiLink registryPath Special
101 HiLink registryRemove PreProc
102 HiLink registryGUID Identifier
103 HiLink registrySpecial Special
104 HiLink registrySubKey Type
105 HiLink registryString String
106 HiLink registryHex Number
107 HiLink registryDword Number
108
109 delcommand HiLink
110endif
111
112
113let b:current_syntax = "registry"
114
115" vim:ts=8