3 " Maintainer: Nick Hibma <n_hibma@webweaving.org>
4 " Last Change: 2001 May 10
5 " Location: http://www.etla.net/~n_hibma/vim/syntax/perl.vim
7 " Please download most recent version first before mailing
9 " See also the file perl.vim.regression.pl to check whether your
10 " modifications work in the most odd cases
11 " http://www.etla.net/~n_hibma/vim/syntax/perl.vim.regression.pl
13 " Original version: Sonia Heimann <niania@netsurf.org>
14 " Thanks to many people for their contribution. They made it work, not me.
16 " The following parameters are available for tuning the
17 " perl syntax highlighting, with defaults given:
19 " unlet perl_include_pod
20 " unlet perl_want_scope_in_variables
21 " unlet perl_extended_vars
22 " unlet perl_string_as_statement
23 " unlet perl_no_sync_on_sub
24 " unlet perl_no_sync_on_global_var
25 " let perl_sync_dist = 100
28 " Remove any old syntax stuff that was loaded (5.x) or quit when a syntax file
29 " was already loaded (6.x).
32 elseif exists("b:current_syntax")
36 " Unset perl_fold if it set but vim doesn't support it.
37 if version < 600 && exists("perl_fold")
42 " POD starts with ^=<word> and ends with ^=cut
44 if exists("perl_include_pod")
45 " Include a while extra syntax file
46 syn include @Pod <sfile>:p:h/pod.vim
47 unlet b:current_syntax
48 syn region perlPOD start="^=[a-z]" end="^=cut" contains=@Pod,perlTodo keepend
50 " Use only the bare minimum of rules
51 syn region perlPOD start="^=[a-z]" end="^=cut"
57 syn keyword perlConditional if elsif unless switch eq ne gt lt ge le cmp not and or xor
58 syn keyword perlConditional else nextgroup=perlElseIfError skipwhite skipnl skipempty
59 syn keyword perlRepeat while for foreach do until
60 syn keyword perlOperator defined undef and or not bless ref
61 if exists("perl_fold")
62 " in Vim if BEGIN/END is a keyword the perlBEGINENDFold does not work
63 syn match perlControl "BEGIN" contained
64 syn match perlControl "END" contained
66 syn keyword perlControl BEGIN END
69 syn keyword perlStatementStorage my local our
70 syn keyword perlStatementControl goto return last next continue redo
71 syn keyword perlStatementScalar chomp chop chr crypt index lc lcfirst length ord pack reverse rindex sprintf substr uc ucfirst
72 syn keyword perlStatementRegexp pos quotemeta split study
73 syn keyword perlStatementNumeric abs atan2 cos exp hex int log oct rand sin sqrt srand
74 syn keyword perlStatementList splice unshift shift push pop split join reverse grep map sort unpack
75 syn keyword perlStatementHash each exists keys values tie tied
76 syn keyword perlStatementIOfunc carp confess croak dbmclose dbmopen die syscall
77 syn keyword perlStatementFiledesc binmode close closedir eof fileno getc lstat print printf readdir rewinddir select stat tell telldir write nextgroup=perlFiledescStatementNocomma
78 syn keyword perlStatementFiledesc fcntl flock ioctl open opendir read seek seekdir sysopen sysread sysseek syswrite truncate nextgroup=perlFiledescStatementComma
79 syn keyword perlStatementVector pack vec
80 syn keyword perlStatementFiles chdir chmod chown chroot glob link mkdir readlink rename rmdir symlink umask unlink utime
81 syn match perlStatementFiles "-[rwxoRWXOezsfdlpSbctugkTBMAC]\>"
82 syn keyword perlStatementFlow caller die dump eval exit wantarray
83 syn keyword perlStatementInclude require
84 syn match perlStatementInclude "\(use\|no\)\s\+\(integer\>\|strict\>\|lib\>\|sigtrap\>\|subs\>\|vars\>\|warnings\>\|utf8\>\|byte\>\)\="
85 syn keyword perlStatementScope import
86 syn keyword perlStatementProc alarm exec fork getpgrp getppid getpriority kill pipe setpgrp setpriority sleep system times wait waitpid
87 syn keyword perlStatementSocket accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair
88 syn keyword perlStatementIPC msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite
89 syn keyword perlStatementNetwork endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent
90 syn keyword perlStatementPword getpwuid getpwnam getpwent setpwent endpwent getgrent getgrgid
91 syn keyword perlStatementTime gmtime localtime time times
93 syn keyword perlStatementMisc warn formline reset scalar new delete
95 syn keyword perlTodo TODO TBD FIXME XXX contained
99 " Should be cleaned up to better handle identifiers in particular situations
100 " (in hash keys for example)
102 " Plain identifiers: $foo, @foo, $#foo, %foo, &foo and dereferences $$foo, @$foo, etc.
103 " We do not process complex things such as @{${"foo"}}. Too complicated, and
104 " too slow. And what is after the -> is *not* considered as part of the
105 " variable - there again, too complicated and too slow.
107 " Special variables first ($^A, ...) and ($|, $', ...)
108 syn match perlVarPlain "$^[ADEFHILMOPSTWX]\="
109 syn match perlVarPlain "$[\\\"\[\]'&`+*.,;=%~!?@$<>(0-9-]"
110 " Same as above, but avoids confusion in $::foo (equivalent to $main::foo)
111 syn match perlVarPlain "$:[^:]"
112 " These variables are not recognized within matches.
113 syn match perlVarNotInMatches "$[|)]"
114 " This variable is not recognized within matches delimited by m//.
115 syn match perlVarSlash "$/"
117 " And plain identifiers
118 syn match perlPackageRef "\(\h\w*\)\=\(::\|'\)\I"me=e-1 contained
120 " To highlight packages in variables as a scope reference - i.e. in $pack::var,
121 " pack:: is a scope, just set "perl_want_scope_in_variables"
122 " If you *want* complex things like @{${"foo"}} to be processed,
123 " just set the variable "perl_extended_vars"...
125 " FIXME value between {} should be marked as string. is treated as such by Perl.
126 " At the moment it is marked as something greyish instead of read. Probably todo
127 " with transparency. Or maybe we should handle the bare word in that case. or make it into
129 if exists("perl_want_scope_in_variables")
130 syn match perlVarPlain "\\\=\([@%$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember
131 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" contains=perlPackageRef nextgroup=perlVarMember,perlVarSimpleMember
133 syn match perlVarPlain "\\\=\([@%$]\|\$#\)\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember
134 syn match perlFunctionName "\\\=&\$*\(\I\i*\)\=\(\(::\|'\)\I\i*\)*\>" nextgroup=perlVarMember,perlVarSimpleMember
137 if exists("perl_extended_vars")
138 syn cluster perlExpr contains=perlStatementScalar,perlStatementRegexp,perlStatementNumeric,perlStatementList,perlStatementHash,perlStatementFiles,perlStatementTime,perlStatementMisc,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock,perlShellCommand,perlNumber,perlStringUnexpanded,perlString,perlQQ
139 syn region perlVarBlock matchgroup=perlVarPlain start="\($#\|[@%\$]\){" skip="\\}" end="}" contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
140 syn match perlVarPlain "\\\=\(\$#\|[@%&$]\)\$*{\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember
141 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\={" skip="\\}" end="}" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
142 syn match perlVarSimpleMember "\(->\)\={\I\i*}" nextgroup=perlVarMember,perlVarSimpleMember contains=perlVarSimpleMemberName contained
143 syn match perlVarSimpleMemberName "\I\i*" contained
144 syn region perlVarMember matchgroup=perlVarPlain start="\(->\)\=\[" skip="\\]" end="]" contained contains=@perlExpr nextgroup=perlVarMember,perlVarSimpleMember
148 syn match perlFiledescRead "[<]\h\w\+[>]"
150 syn match perlFiledescStatementComma "\s*(\=\s*\h\w*\>\s*," transparent contained contains=perlFiledescStatement
151 syn match perlFiledescStatementNocomma "\s*(\=\s*\h\w*\>\s\+[^,]"me=e-1 transparent contained contains=perlFiledescStatement
153 syn match perlFiledescStatement "\h\w\+" contained
155 " Special characters in strings and matches
156 syn match perlSpecialString "\\\(\d\+\|[xX]\x\+\|c\u\|.\)" contained
157 syn match perlSpecialStringU "\\['\\]" contained
158 syn match perlSpecialMatch "{\d\(,\d\)\=}" contained
159 syn match perlSpecialMatch "\[\(\]\|-\)\=[^\[\]]*\(\[\|\-\)\=\]" contained
160 syn match perlSpecialMatch "[+*()?.]" contained
161 syn match perlSpecialMatch "(?[#:=!]" contained
162 syn match perlSpecialMatch "(?[imsx]\+)" contained
163 " FIXME the line below does not work. It should mark end of line and
164 " begin of line as perlSpecial.
165 " syn match perlSpecialBEOM "^\^\|\$$" contained
169 " Highlight lines with only whitespace (only in blank delimited here documents) as errors
170 syn match perlNotEmptyLine "^\s\+$" contained
171 " Highlight '} else if (...) {', it should be '} else { if (...) { ' or
173 syn keyword perlElseIfError if contained
175 " Variable interpolation
177 " These items are interpolated inside "" strings and similar constructs.
178 syn cluster perlInterpDQ contains=perlSpecialString,perlVarPlain,perlVarNotInMatches,perlVarSlash,perlVarBlock
179 " These items are interpolated inside '' strings and similar constructs.
180 syn cluster perlInterpSQ contains=perlSpecialStringU
181 " These items are interpolated inside m// matches and s/// substitutions.
182 syn cluster perlInterpSlash contains=perlSpecialString,perlSpecialMatch,perlVarPlain,perlVarBlock,perlSpecialBEOM
183 " These items are interpolated inside m## matches and s### substitutions.
184 syn cluster perlInterpMatch contains=@perlInterpSlash,perlVarSlash
187 syn region perlShellCommand matchgroup=perlMatchStartEnd start="`" end="`" contains=@perlInterpDQ
192 syn match perlNumber "[-+]\=\(\<\d[[:digit:]_]*\(L\=\|[eE][\-+]\=\d\+\)\>\|0[xX]\x[[:xdigit:]_]*\>\)"
194 " Simple version of searches and matches
195 " caters for m//, m## and m[] (and the !/ variant)
196 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
197 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]#+ end=+#[cgimosx]*+ contains=@perlInterpMatch
198 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]\[+ end=+\][cgimosx]*+ contains=@perlInterpMatch
200 " A special case for m!!x which allows for comments and extra whitespace in the pattern
201 syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]!+ end=+![cgimosx]*+ contains=@perlInterpSlash,perlComment
203 " Below some hacks to recognise the // variant. This is virtually impossible to catch in all
204 " cases as the / is used in so many other ways, but these should be the most obvious ones.
205 syn region perlMatch matchgroup=perlMatchStartEnd start=+^split /+lc=5 start=+[^$@%]\<split /+lc=6 start=+^if /+lc=2 start=+[^$@%]if /+lc=3 start=+[!=]\~\s*/+lc=2 start=+[(~]/+lc=1 start=+\.\./+lc=2 start=+\s/[^= \t0-9$@%]+lc=1,me=e-1,rs=e-1 start=+^/+ skip=+\\/+ end=+/[cgimosx]*+ contains=@perlInterpSlash
208 " caters for s///, s### and s[][]
209 " perlMatch is the first part, perlSubstitution* is the substitution part
210 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlSubstitutionSQ
211 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s"+ end=+"+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionDQ
212 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s/+ end=+/+me=e-1 contains=@perlInterpSlash nextgroup=perlSubstitutionSlash
213 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s#+ end=+#+me=e-1 contains=@perlInterpMatch nextgroup=perlSubstitutionHash
214 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s\[+ end=+\]+ contains=@perlInterpMatch nextgroup=perlSubstitutionBracket skipwhite skipempty skipnl
215 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s{+ end=+}+ contains=@perlInterpMatch nextgroup=perlSubstitutionCurly skipwhite skipempty skipnl
216 syn region perlSubstitutionSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[ecgimosx]*+ contained contains=@perlInterpSQ
217 syn region perlSubstitutionDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[ecgimosx]*+ contained contains=@perlInterpDQ
218 syn region perlSubstitutionSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[ecgimosx]*+ contained contains=@perlInterpDQ
219 syn region perlSubstitutionHash matchgroup=perlMatchStartEnd start=+#+ end=+#[ecgimosx]*+ contained contains=@perlInterpDQ
220 syn region perlSubstitutionBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][ecgimosx]*+ contained contains=@perlInterpDQ
221 syn region perlSubstitutionCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[ecgimosx]*+ contained contains=@perlInterpDQ
223 " A special case for m!!x which allows for comments and extra whitespace in the pattern
224 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<s!+ end=+!+me=e-1 contains=@perlInterpSlash,perlComment nextgroup=perlSubstitutionPling
225 syn region perlSubstitutionPling matchgroup=perlMatchStartEnd start=+!+ end=+![ecgimosx]*+ contained contains=@perlInterpDQ
228 " caters for tr///, tr### and tr[][]
229 " perlMatch is the first part, perlTranslation* is the second, translator part.
230 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)'+ end=+'+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSQ
231 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)"+ end=+"+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationDQ
232 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)/+ end=+/+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationSlash
233 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)#+ end=+#+me=e-1 contains=@perlInterpSQ nextgroup=perlTranslationHash
234 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\)\[+ end=+\]+ contains=@perlInterpSQ nextgroup=perlTranslationBracket skipwhite skipempty skipnl
235 syn region perlMatch matchgroup=perlMatchStartEnd start=+\<\(tr\|y\){+ end=+}+ contains=@perlInterpSQ nextgroup=perlTranslationCurly skipwhite skipempty skipnl
236 syn region perlTranslationSQ matchgroup=perlMatchStartEnd start=+'+ end=+'[cds]*+ contained
237 syn region perlTranslationDQ matchgroup=perlMatchStartEnd start=+"+ end=+"[cds]*+ contained
238 syn region perlTranslationSlash matchgroup=perlMatchStartEnd start=+/+ end=+/[cds]*+ contained
239 syn region perlTranslationHash matchgroup=perlMatchStartEnd start=+#+ end=+#[cds]*+ contained
240 syn region perlTranslationBracket matchgroup=perlMatchStartEnd start=+\[+ end=+\][cds]*+ contained
241 syn region perlTranslationCurly matchgroup=perlMatchStartEnd start=+{+ end=+}[cds]*+ contained
244 " The => operator forces a bareword to the left of it to be interpreted as
246 syn match perlString "\<\I\i*\s*=>"me=e-2
248 " Strings and q, qq, qw and qr expressions
251 syn region perlBrackets start=+(+ end=+)+ contained transparent contains=perlBrackets,@perlStringSQ
253 syn region perlStringUnexpanded matchgroup=perlStringStartEnd start="'" end="'" contains=@perlInterpSQ
254 syn region perlString matchgroup=perlStringStartEnd start=+"+ end=+"+ contains=@perlInterpDQ
255 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q#+ end=+#+ contains=@perlInterpSQ
256 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q|+ end=+|+ contains=@perlInterpSQ
257 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q(+ end=+)+ contains=@perlInterpSQ,perlBrackets
258 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q{+ end=+}+ contains=@perlInterpSQ
259 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q/+ end=+/+ contains=@perlInterpSQ
260 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]#+ end=+#+ contains=@perlInterpDQ
261 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]|+ end=+|+ contains=@perlInterpDQ
262 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx](+ end=+)+ contains=@perlInterpDQ,perlBrackets
263 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]{+ end=+}+ contains=@perlInterpDQ
264 syn region perlQQ matchgroup=perlStringStartEnd start=+\<q[qx]/+ end=+/+ contains=@perlInterpDQ
265 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw#+ end=+#+ contains=@perlInterpSQ
266 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw|+ end=+|+ contains=@perlInterpSQ
267 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw(+ end=+)+ contains=@perlInterpSQ,perlBrackets
268 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw{+ end=+}+ contains=@perlInterpSQ
269 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qw/+ end=+/+ contains=@perlInterpSQ
270 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr#+ end=+#[imosx]*+ contains=@perlInterpMatch
271 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr|+ end=+|[imosx]*+ contains=@perlInterpMatch
272 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr(+ end=+)[imosx]*+ contains=@perlInterpMatch
273 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr{+ end=+}[imosx]*+ contains=@perlInterpMatch
274 syn region perlQQ matchgroup=perlStringStartEnd start=+\<qr/+ end=+/[imosx]*+ contains=@perlInterpSlash
276 " Constructs such as print <<EOF [...] EOF, 'here' documents
279 " XXX Any statements after the identifier are in perlString colour (i.e.
280 " 'if $a' in 'print <<EOF if $a').
281 if exists("perl_fold")
282 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ fold
283 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(\S\+\)"+ end=+^\z1$+ contains=@perlInterpDQ fold
284 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(\S\+\)'+ end=+^\z1$+ contains=@perlInterpSQ fold
285 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine fold
286 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine fold
288 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\z(\I\i*\)+ end=+^\z1$+ contains=@perlInterpDQ
289 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*"\z(\S\+\)"+ end=+^\z1$+ contains=@perlInterpDQ
290 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*'\z(\S\+\)'+ end=+^\z1$+ contains=@perlInterpSQ
291 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*""+ end=+^$+ contains=@perlInterpDQ,perlNotEmptyLine
292 syn region perlHereDoc matchgroup=perlStringStartEnd start=+<<\s*''+ end=+^$+ contains=@perlInterpSQ,perlNotEmptyLine
295 syn match perlUntilEOFstart "<<EOF.*" nextgroup=perlUntilEOFDQ skipnl transparent
296 syn match perlUntilEOFstart "<<\s*\"EOF\".*" nextgroup=perlUntilEOFDQ skipnl transparent
297 syn match perlUntilEOFstart "<<\s*'EOF'.*" nextgroup=perlUntilEOFSQ skipnl transparent
298 syn match perlUntilEOFstart "<<\s*\"\".*" nextgroup=perlUntilEmptyDQ skipnl transparent
299 syn match perlUntilEOFstart "<<\s*''.*" nextgroup=perlUntilEmptySQ skipnl transparent
300 syn region perlUntilEOFDQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpDQ contained
301 syn region perlUntilEOFSQ matchgroup=perlStringStartEnd start=++ end="^EOF$" contains=@perlInterpSQ contained
302 syn region perlUntilEmptySQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpDQ,perlNotEmptyLine contained
303 syn region perlUntilEmptyDQ matchgroup=perlStringStartEnd start=++ end="^$" contains=@perlInterpSQ,perlNotEmptyLine contained
309 syn match perlPackageDecl "^\s*package\s\+\S\+" contains=perlStatementPackage
310 syn keyword perlStatementPackage package contained
313 " sub [name] [(prototype)] {
315 syn region perlFunction start="\s*sub\>" end="[;{]"he=e-1 contains=perlStatementSub,perlFunctionPrototype,perlFunctionPRef,perlFunctionName,perlComment
316 syn keyword perlStatementSub sub contained
318 syn match perlFunctionPrototype "([^)]*)" contained
319 if exists("perl_want_scope_in_variables")
320 syn match perlFunctionPRef "\h\w*::" contained
321 syn match perlFunctionName "\h\w*[^:]" contained
323 syn match perlFunctionName "\h[[:alnum:]_:]*" contained
327 " All other # are comments, except ^#!
328 syn match perlComment "#.*" contains=perlTodo
329 syn match perlSharpBang "^#!.*"
332 syn region perlFormat matchgroup=perlStatementIOFunc start="^\s*format\s\+\k\+\s*=\s*$"rs=s+6 end="^\s*\.\s*$" contains=perlFormatName,perlFormatField,perlVarPlain
333 syn match perlFormatName "format\s\+\k\+\s*="lc=7,me=e-1 contained
334 syn match perlFormatField "[@^][|<>~]\+\(\.\.\.\)\=" contained
335 syn match perlFormatField "[@^]#[#.]*" contained
336 syn match perlFormatField "@\*" contained
337 syn match perlFormatField "@[^A-Za-z_|<>~#*]"me=e-1 contained
338 syn match perlFormatField "@$" contained
340 " __END__ and __DATA__ clauses
341 if exists("perl_fold")
342 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD fold
344 syntax region perlDATA start="^__\(DATA\|END\)__$" skip="." end="." contains=perlPOD
351 if exists("perl_fold")
352 syn region perlPackageFold start="^package \S\+;$" end="^1;$" transparent fold keepend
353 syn region perlSubFold start="^\z(\s*\)sub\>.*[^};]$" end="^\z1}\s*$" transparent fold
354 syn region perlBEGINENDFold start="^\z(\s*\)BEGIN\>.*[^};]$" end="^\z1}\s*$" transparent fold
356 setlocal foldmethod=syntax
360 if version >= 508 || !exists("did_perl_syn_inits")
362 let did_perl_syn_inits = 1
363 command -nargs=+ HiLink hi link <args>
365 command -nargs=+ HiLink hi def link <args>
368 " The default highlighting.
369 HiLink perlSharpBang PreProc
370 HiLink perlControl PreProc
371 HiLink perlInclude Include
372 HiLink perlSpecial Special
373 HiLink perlString String
374 HiLink perlCharacter Character
375 HiLink perlNumber Number
377 HiLink perlIdentifier Identifier
378 HiLink perlLabel Label
379 HiLink perlStatement Statement
380 HiLink perlConditional Conditional
381 HiLink perlRepeat Repeat
382 HiLink perlOperator Operator
383 HiLink perlFunction Function
384 HiLink perlFunctionPrototype perlFunction
385 HiLink perlComment Comment
387 if exists("perl_string_as_statement")
388 HiLink perlStringStartEnd perlStatement
390 HiLink perlStringStartEnd perlString
392 HiLink perlList perlStatement
393 HiLink perlMisc perlStatement
394 HiLink perlVarPlain perlIdentifier
395 HiLink perlFiledescRead perlIdentifier
396 HiLink perlFiledescStatement perlIdentifier
397 HiLink perlVarSimpleMember perlIdentifier
398 HiLink perlVarSimpleMemberName perlString
399 HiLink perlVarNotInMatches perlIdentifier
400 HiLink perlVarSlash perlIdentifier
401 HiLink perlQQ perlString
403 HiLink perlHereDoc perlString
405 HiLink perlUntilEOFStart perlStringStartEnd
406 HiLink perlUntilEOFDQ perlString
407 HiLink perlUntilEOFSQ perlString
408 HiLink perlUntilEmptyDQ perlString
409 HiLink perlUntilEmptySQ perlString
410 HiLink perlUntilEOF perlString
412 HiLink perlStringUnexpanded perlString
413 HiLink perlSubstitutionSQ perlString
414 HiLink perlSubstitutionDQ perlString
415 HiLink perlSubstitutionSlash perlString
416 HiLink perlSubstitutionHash perlString
417 HiLink perlSubstitutionBracket perlString
418 HiLink perlSubstitutionCurly perlString
419 HiLink perlSubstitutionPling perlString
420 HiLink perlTranslationSlash perlString
421 HiLink perlTranslationHash perlString
422 HiLink perlTranslationBracket perlString
423 HiLink perlTranslationCurly perlString
424 HiLink perlMatch perlString
425 HiLink perlMatchStartEnd perlStatement
426 HiLink perlFormatName perlIdentifier
427 HiLink perlFormatField perlString
428 HiLink perlPackageDecl perlType
429 HiLink perlStorageClass perlType
430 HiLink perlPackageRef perlType
431 HiLink perlStatementPackage perlStatement
432 HiLink perlStatementSub perlStatement
433 HiLink perlStatementStorage perlStatement
434 HiLink perlStatementControl perlStatement
435 HiLink perlStatementScalar perlStatement
436 HiLink perlStatementRegexp perlStatement
437 HiLink perlStatementNumeric perlStatement
438 HiLink perlStatementList perlStatement
439 HiLink perlStatementHash perlStatement
440 HiLink perlStatementIOfunc perlStatement
441 HiLink perlStatementFiledesc perlStatement
442 HiLink perlStatementVector perlStatement
443 HiLink perlStatementFiles perlStatement
444 HiLink perlStatementFlow perlStatement
445 HiLink perlStatementScope perlStatement
446 HiLink perlStatementInclude perlStatement
447 HiLink perlStatementProc perlStatement
448 HiLink perlStatementSocket perlStatement
449 HiLink perlStatementIPC perlStatement
450 HiLink perlStatementNetwork perlStatement
451 HiLink perlStatementPword perlStatement
452 HiLink perlStatementTime perlStatement
453 HiLink perlStatementMisc perlStatement
454 HiLink perlFunctionName perlIdentifier
455 HiLink perlFunctionPRef perlType
456 HiLink perlPOD perlComment
457 HiLink perlShellCommand perlString
458 HiLink perlSpecialAscii perlSpecial
459 HiLink perlSpecialDollar perlSpecial
460 HiLink perlSpecialString perlSpecial
461 HiLink perlSpecialStringU perlSpecial
462 HiLink perlSpecialMatch perlSpecial
463 HiLink perlSpecialBEOM perlSpecial
464 HiLink perlDATA perlComment
466 HiLink perlBrackets Error
469 HiLink perlNotEmptyLine Error
470 HiLink perlElseIfError Error
475 " Syncing to speed up processing
477 if !exists("perl_no_sync_on_sub")
478 syn sync match perlSync grouphere NONE "^\s*package\s"
479 syn sync match perlSync grouphere perlFunction "^\s*sub\s"
480 syn sync match perlSync grouphere NONE "^}"
483 if !exists("perl_no_sync_on_global_var")
484 syn sync match perlSync grouphere NONE "^$\I[[:alnum:]_:]+\s*=\s*{"
485 syn sync match perlSync grouphere NONE "^[@%]\I[[:alnum:]_:]+\s*=\s*("
488 if exists("perl_sync_dist")
489 execute "syn sync maxlines=" . perl_sync_dist
491 syn sync maxlines=100
494 syn sync match perlSyncPOD grouphere perlPOD "^=pod"
495 syn sync match perlSyncPOD grouphere perlPOD "^=head"
496 syn sync match perlSyncPOD grouphere perlPOD "^=item"
497 syn sync match perlSyncPOD grouphere NONE "^=cut"
499 let b:current_syntax = "perl"