3# http://www.sublimetext.com/docs/3/syntax.html
9scope: source.powershell
14 0: punctuation.definition.comment.block.begin.powershell
16 - meta_scope: comment.block.powershell
19 0: punctuation.definition.comment.block.end.powershell
21 - include: commentEmbeddedDocs
22 - match: '[2-6]>&1|>>|>|<<|<|>|>\||[1-6]>|[1-6]>>'
23 scope: keyword.operator.redirection.powershell
25 - include: commentLine
27 - include: subexpression
30 - include: UsingDirective
33 - include: doubleQuotedString
34 - include: scriptblock
35 - include: doubleQuotedStringEscapes
36 - match: '[''\x{2018}-\x{201B}]'
38 0: punctuation.definition.string.begin.powershell
40 - meta_scope: string.quoted.single.powershell
41 - match: '[''\x{2018}-\x{201B}]{2}'
42 scope: constant.character.escape.powershell
43 - match: '[''\x{2018}-\x{201B}]'
45 0: punctuation.definition.string.end.powershell
47 - match: '(@["\x{201C}-\x{201E}])\s*$'
49 1: punctuation.definition.string.begin.powershell
51 - meta_scope: string.quoted.double.heredoc.powershell
52 - match: '^["\x{201C}-\x{201E}]@'
54 0: punctuation.definition.string.end.powershell
56 - include: variableNoProperty
57 - include: doubleQuotedStringEscapes
58 - include: interpolation
59 - match: '(@[''\x{2018}-\x{201B}])\s*$'
61 1: punctuation.definition.string.begin.powershell
63 - meta_scope: string.quoted.single.heredoc.powershell
64 - match: '^[''\x{2018}-\x{201B}]@'
66 0: punctuation.definition.string.end.powershell
68 - include: numericConstant
71 1: keyword.other.array.begin.powershell
72 2: punctuation.section.group.begin.powershell
74 - meta_scope: meta.group.array-expression.powershell
77 0: punctuation.section.group.end.powershell
81 comment: "TODO: move to repo; make recursive."
83 1: keyword.other.substatement.powershell
84 2: punctuation.definition.subexpression.powershell
85 3: punctuation.section.group.begin.powershell
87 - meta_scope: meta.group.complex.subexpression.powershell
90 0: punctuation.section.group.end.powershell
93 - match: '(\b(([A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat))\b)'
94 scope: support.function.powershell
95 - match: (?<!\w|-|\.)((?i:begin|break|catch|clean|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)|%|\?)(?!\w)
96 scope: keyword.control.powershell
97 - match: '(?<!\w|-|[^\)]\.)((?i:(foreach|where)(?!-object))|%|\?)(?!\w)'
98 scope: keyword.control.powershell
99 - match: (?<!\w)(--%)(?!\w)
100 comment: This should be moved to the repository at some point.
102 1: keyword.control.powershell
107 scope: string.unquoted.powershell
108 - match: (?<!\w)((?i:hidden|static))(?!\w)
109 comment: This should only be relevant inside a class but will require a rework of how classes are matched. This is a temp fix.
110 scope: storage.modifier.powershell
111 - match: '(?<!\w|-)((?i:class)|%|\?)(?:\s)+((?:\p{L}|\d|_|-|)+)\b'
112 comment: capture should be entity.name.type, but it doesn't provide a good color in the default schema.
114 1: storage.type.powershell
115 2: entity.name.function
116 - match: (?<!\w)-(?i:is(?:not)?|as)\b
117 scope: keyword.operator.comparison.powershell
118 - match: '(?<!\w)-(?i:[ic]?(?:eq|ne|[gl][te]|(?:not)?(?:like|match|contains|in)|replace))(?!\p{L})'
119 scope: keyword.operator.comparison.powershell
120 - match: '(?<!\w)-(?i:join|split)(?!\p{L})|!'
121 scope: keyword.operator.unary.powershell
122 - match: '(?<!\w)-(?i:and|or|not|xor)(?!\p{L})|!'
123 scope: keyword.operator.logical.powershell
124 - match: '(?<!\w)-(?i:band|bor|bnot|bxor|shl|shr)(?!\p{L})'
125 scope: keyword.operator.bitwise.powershell
126 - match: '(?<!\w)-(?i:f)(?!\p{L})'
127 scope: keyword.operator.string-format.powershell
128 - match: "[+%*/-]?=|[+/*%-]"
129 scope: keyword.operator.assignment.powershell
130 - match: '\|{2}|&{2}|;'
131 scope: punctuation.terminator.statement.powershell
132 - match: '&|(?<!\w)\.(?= )|`|,|\|'
133 scope: keyword.operator.other.powershell
134 - match: (?<!\s|^)\.\.(?=\-?\d|\(|\$)
135 comment: This is very imprecise, is there a syntax for 'must come after...'
136 scope: keyword.operator.range.powershell
138 - match: (?<=#)(?i:(requires))\s
140 0: keyword.control.requires.powershell
142 - meta_scope: meta.requires.powershell
145 - match: \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version|Assembly|PSEdition)
146 scope: keyword.other.powershell
147 - match: '(?<!-)\b\p{L}+|\d+(?:\.\d+)*'
148 scope: variable.parameter.powershell
151 - match: (?<!\w)(?i:(using))\s+(?i:(namespace|module))\s+(?i:((?:\w+(?:\.)?)+))
153 1: keyword.control.using.powershell
154 2: keyword.other.powershell
155 3: variable.parameter.powershell
157 - match: '(\[)\s*\b(?i)(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength|supportswildcards)\b'
159 1: punctuation.section.bracket.begin.powershell
160 2: support.function.attribute.powershell
162 - meta_scope: meta.attribute.powershell
165 1: punctuation.section.bracket.end.powershell
169 0: punctuation.section.group.begin.powershell
173 0: punctuation.section.group.end.powershell
176 - match: (?i)\b(mandatory|valuefrompipeline|valuefrompipelinebypropertyname|valuefromremainingarguments|position|parametersetname|defaultparametersetname|supportsshouldprocess|supportspaging|positionalbinding|helpuri|confirmimpact|helpmessage)\b(?:\s+)?(=)?
178 1: variable.parameter.attribute.powershell
179 2: keyword.operator.assignment.powershell
181 - match: '(?:(\p{L}|\d|_|-|\\|\:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b'
182 comment: "Verb-Noun pattern:"
183 scope: support.function.powershell
184 - match: (?<!\w)(?i:foreach-object)(?!\w)
185 comment: Builtin cmdlets with reserved verbs
186 scope: support.function.powershell
187 - match: (?<!\w)(?i:where-object)(?!\w)
188 comment: Builtin cmdlets with reserved verbs
189 scope: support.function.powershell
190 - match: (?<!\w)(?i:sort-object)(?!\w)
191 comment: Builtin cmdlets with reserved verbs
192 scope: support.function.powershell
193 - match: (?<!\w)(?i:tee-object)(?!\w)
194 comment: Builtin cmdlets with reserved verbs
195 scope: support.function.powershell
197 - match: (?:^|\G)(?i:\s*(\.)(COMPONENT|DESCRIPTION|EXAMPLE|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|ROLE|SYNOPSIS))\s*$
198 comment: these embedded doc keywords do not support arguments, must be the only thing on the line
199 scope: comment.documentation.embedded.powershell
201 1: constant.string.documentation.powershell
202 2: keyword.operator.documentation.powershell
203 - match: (?:^|\G)(?i:\s*(\.)(EXTERNALHELP|FORWARDHELP(?:CATEGORY|TARGETNAME)|PARAMETER|REMOTEHELPRUNSPACE))\s+(.+?)\s*$
204 comment: these embedded doc keywords require arguments though the type required may be inconsistent, they may not all be able to use the same argument match
205 scope: comment.documentation.embedded.powershell
207 1: constant.string.documentation.powershell
208 2: keyword.operator.documentation.powershell
209 3: keyword.operator.documentation.powershell
211 - match: '(?<![`\\-])(#)#*'
213 1: punctuation.definition.comment.powershell
215 - meta_scope: comment.line.powershell
218 1: punctuation.definition.comment.powershell
220 - include: commentEmbeddedDocs
221 - include: RequiresDirective
223 - match: '["\x{201C}-\x{201E}]'
225 0: punctuation.definition.string.begin.powershell
227 - meta_scope: string.quoted.double.powershell
228 - match: '(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}\b'
229 - include: variableNoProperty
230 - include: doubleQuotedStringEscapes
231 - match: '["\x{201C}-\x{201E}]{2}'
232 scope: constant.character.escape.powershell
233 - include: interpolation
235 scope: keyword.other.powershell
236 - match: '["\x{201C}-\x{201E}]'
238 0: punctuation.definition.string.end.powershell
240 doubleQuotedStringEscapes:
241 - match: '`[`0abefnrtv''"\x{2018}-\x{201E}$]'
242 scope: constant.character.escape.powershell
243 - include: unicodeEscape
245 - match: '^(?:\s*+)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)'
247 0: meta.function.powershell
248 1: storage.type.powershell
249 2: storage.modifier.scope.powershell
250 3: entity.name.function.powershell
254 - include: commentLine
258 1: keyword.other.hashtable.begin.powershell
259 2: punctuation.section.braces.begin.powershell
261 - meta_scope: meta.hashtable.powershell
264 1: punctuation.section.braces.end.powershell
266 - match: \b((?:\'|\")?)(\w+)((?:\'|\")?)(?:\s+)?(=)(?:\s+)?
267 scope: meta.hashtable.assignment.powershell
269 1: punctuation.definition.string.begin.powershell
270 2: variable.other.readwrite.powershell
271 3: punctuation.definition.string.end.powershell
272 4: keyword.operator.assignment.powershell
273 - include: scriptblock
276 - match: (((\$)))((\())
278 1: keyword.other.substatement.powershell
279 2: punctuation.definition.substatement.powershell
280 3: punctuation.section.embedded.substatement.begin.powershell
281 4: punctuation.section.group.begin.powershell
282 5: punctuation.section.embedded.substatement.begin.powershell
284 - meta_scope: meta.embedded.substatement.powershell
285 - meta_content_scope: interpolated.complex.source.powershell
288 0: punctuation.section.group.end.powershell
289 1: punctuation.section.embedded.substatement.end.powershell
293 - match: '(?<!\w)([-+]?0(?:x|X)[0-9a-fA-F_]+(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b'
295 1: constant.numeric.hex.powershell
296 2: keyword.other.powershell
297 - match: '(?<!\w)([-+]?(?:[0-9_]+)?\.[0-9_]+(?:(?:e|E)[0-9]+)?(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b'
299 1: constant.numeric.integer.powershell
300 2: keyword.other.powershell
301 - match: '(?<!\w)([-+]?0(?:b|B)[01_]+(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b'
303 1: constant.numeric.octal.powershell
304 2: keyword.other.powershell
305 - match: '(?<!\w)([-+]?[0-9_]+(?:e|E)(?:[0-9_])?+(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b'
307 1: constant.numeric.integer.powershell
308 2: keyword.other.powershell
309 - match: '(?<!\w)([-+]?[0-9_]+\.(?:e|E)(?:[0-9_])?+(?:F|f|D|d|M|m)?)((?i:[kmgtp]b)?)\b'
311 1: constant.numeric.integer.powershell
312 2: keyword.other.powershell
313 - match: '(?<!\w)([-+]?[0-9_]+[\.]?(?:F|f|D|d|M|m))((?i:[kmgtp]b)?)\b'
315 1: constant.numeric.integer.powershell
316 2: keyword.other.powershell
317 - match: '(?<!\w)([-+]?[0-9_]+[\.]?(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b'
319 1: constant.numeric.integer.powershell
320 2: keyword.other.powershell
324 0: punctuation.section.braces.begin.powershell
326 - meta_scope: meta.scriptblock.powershell
329 0: punctuation.section.braces.end.powershell
335 0: punctuation.section.group.begin.powershell
337 - meta_scope: meta.group.simple.subexpression.powershell
340 0: punctuation.section.group.end.powershell
346 0: punctuation.section.bracket.begin.powershell
350 0: punctuation.section.bracket.end.powershell
352 - match: '(?!\d+|\.)(?:\p{L}|\p{N}|\.)+'
353 scope: storage.type.powershell
356 - match: '`u\{(?:(?:10)?([0-9a-fA-F]){1,4}|0?\g<1>{1,5})}'
357 scope: constant.character.escape.powershell
358 - match: '`u(?:\{[0-9a-fA-F]{,6}.)?'
359 scope: invalid.character.escape.powershell
361 - match: (\$)(?i:(False|Null|True))\b
362 comment: These are special constants.
364 0: constant.language.powershell
365 1: punctuation.definition.variable.powershell
366 - match: '(\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))((?:\.(?:\p{L}|\d|_)+)*\b)?\b'
367 comment: These are the other built-in constants.
369 0: support.constant.variable.powershell
370 1: punctuation.definition.variable.powershell
371 3: variable.other.member.powershell
372 - match: '(\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)((?:\.(?:\p{L}|\d|_)+)*\b)?'
373 comment: Automatic variables are not constants, but they are read-only. In monokai (default) color schema support.variable doesn't have color, so we use constant.
375 0: support.variable.automatic.powershell
376 1: punctuation.definition.variable.powershell
377 3: variable.other.member.powershell
378 - match: '(\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|InformationPreference|LogCommandHealthEvent|LogCommandLifecycleEvent|LogEngineHealthEvent|LogEngineLifecycleEvent|LogProviderHealthEvent|LogProviderLifecycleEvent|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|PSCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoLoadingPreference|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|ProgressPreference|VerbosePreference|WarningPreference|WhatIfPreference))((?:\.(?:\p{L}|\d|_)+)*\b)?\b'
379 comment: Style preference variables as language variables so that they stand out.
381 0: variable.language.powershell
382 1: punctuation.definition.variable.powershell
383 3: variable.other.member.powershell
384 - match: '(?i:(\$|@)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?'
386 0: variable.other.readwrite.powershell
387 1: punctuation.definition.variable.powershell
388 2: storage.modifier.scope.powershell
389 4: variable.other.member.powershell
390 - match: '(?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?'
392 0: variable.other.readwrite.powershell
393 1: punctuation.definition.variable.powershell
394 2: punctuation.section.braces.begin.powershell
395 3: storage.modifier.scope.powershell
396 5: punctuation.section.braces.end.powershell
397 6: variable.other.member.powershell
398 - match: '(?i:(\$|@)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))((?:\.(?:\p{L}|\d|_)+)*\b)?'
400 0: variable.other.readwrite.powershell
401 1: punctuation.definition.variable.powershell
402 2: support.variable.drive.powershell
403 4: variable.other.member.powershell
404 - match: '(?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))((?:\.(?:\p{L}|\d|_)+)*\b)?'
406 0: variable.other.readwrite.powershell
407 1: punctuation.definition.variable.powershell
408 2: punctuation.section.braces.begin.powershell
409 3: support.variable.drive.powershell
410 5: punctuation.section.braces.end.powershell
411 6: variable.other.member.powershell
413 - match: (\$)(?i:(False|Null|True))\b
414 comment: These are special constants.
416 0: constant.language.powershell
417 1: punctuation.definition.variable.powershell
418 - match: (\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))\b
419 comment: These are the other built-in constants.
421 0: support.constant.variable.powershell
422 1: punctuation.definition.variable.powershell
423 3: variable.other.member.powershell
424 - match: '(\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\b)'
425 comment: Automatic variables are not constants, but they are read-only...
427 0: support.variable.automatic.powershell
428 1: punctuation.definition.variable.powershell
429 3: variable.other.member.powershell
430 - match: (\$)(?i:(ConfirmPreference|DebugPreference|ErrorActionPreference|ErrorView|FormatEnumerationLimit|InformationPreference|LogCommandHealthEvent|LogCommandLifecycleEvent|LogEngineHealthEvent|LogEngineLifecycleEvent|LogProviderHealthEvent|LogProviderLifecycleEvent|MaximumAliasCount|MaximumDriveCount|MaximumErrorCount|MaximumFunctionCount|MaximumHistoryCount|MaximumVariableCount|OFS|OutputEncoding|PSCulture|PSDebugContext|PSDefaultParameterValues|PSEmailServer|PSItem|PSModuleAutoLoadingPreference|PSModuleAutoloadingPreference|PSSenderInfo|PSSessionApplicationName|PSSessionConfigurationName|PSSessionOption|ProgressPreference|VerbosePreference|WarningPreference|WhatIfPreference))\b
431 comment: Style preference variables as language variables so that they stand out.
433 0: variable.language.powershell
434 1: punctuation.definition.variable.powershell
435 3: variable.other.member.powershell
436 - match: '(?i:(\$)(global|local|private|script|using|workflow):((?:\p{L}|\d|_)+))'
438 0: variable.other.readwrite.powershell
439 1: punctuation.definition.variable.powershell
440 2: storage.modifier.scope.powershell
441 4: variable.other.member.powershell
442 - match: '(?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))'
444 0: variable.other.readwrite.powershell
445 1: punctuation.definition.variable.powershell
446 2: storage.modifier.scope.powershell
447 4: keyword.other.powershell
448 5: variable.other.member.powershell
449 - match: '(?i:(\$)((?:\p{L}|\d|_)+:)?((?:\p{L}|\d|_)+))'
451 0: variable.other.readwrite.powershell
452 1: punctuation.definition.variable.powershell
453 2: support.variable.drive.powershell
454 4: variable.other.member.powershell
455 - match: '(?i:(\$)(\{)((?:\p{L}|\d|_)+:)?([^}]*[^}`])(\}))'
457 0: variable.other.readwrite.powershell
458 1: punctuation.definition.variable.powershell
459 2: punctuation.section.braces.begin
460 3: support.variable.drive.powershell
461 5: punctuation.section.braces.end
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list