You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Variables that are built-in constants are not highlighted, like $Error and $PSVersionTable #218
Make sure you are able to repro it on the latest version
Search the existing issues.
Steps to reproduce
Noticed that both VSCode and GitHub doesn't highlight some variables, like $Error and $PSVersionTable
This:
```powershell#Requires -Version 5.1<# .SYNOPSIS This is just to test code highlighting.#># Input and expected output[OutputType([System.Void])]Param()# Preference variables$ErrorActionPreference = 'Stop'$InformationPreference = 'Continue'# User defined variable$SomeVariable = [string] 'Text'# Built-in constants$Error$PSHOME$PSVersionTable# Valuesstring without quotes'string with quotes'```
Looks like this on GitHub:
#Requires -Version5.1<#.SYNOPSIS This is just to test code highlighting.#># Input and expected output
[OutputType([System.Void])]
Param()
# Preference variables$ErrorActionPreference='Stop'$InformationPreference='Continue'# User defined variable$SomeVariable= [string] 'Text'# Built-in constants$Error$PSHOME$PSVersionTable# Values
string without quotes
'string with quotes'
changed the title [-]Some variables are not highlighted, like `$Error` and `$PSVersionTable`[/-][+]Variables that are built-in constants are not highlighted, like `$Error` and `$PSVersionTable`[/+]on Mar 17, 2024
Activity
[-]Some variables are not highlighted, like `$Error` and `$PSVersionTable`[/-][+]Variables that are built-in constants are not highlighted, like `$Error` and `$PSVersionTable`[/+]o-l-a-v commentedon Mar 1, 2026
Is the problem that the defined textmate scope does not have a theme selector?
In https://github.com/microsoft/vscode/blob/main/extensions/powershell/syntaxes/powershell.tmLanguage.json I see:
{ "captures": { "0": { "name": "support.constant.variable.powershell" }, "1": { "name": "punctuation.definition.variable.powershell" }, "3": { "name": "variable.other.member.powershell" } }, "comment": "These are the other built-in constants.", "match": "(\\$)(?i:(Error|ExecutionContext|Host|Home|PID|PsHome|PsVersionTable|ShellID))\\b" }Which results in textmate scopes
support.constant.variable.powershell source.powershell, which says foregroundNo theme selector.So maybe it just uses wrong textmate scope?
o-l-a-v commentedon Mar 1, 2026
Dracula theme have worked around this like so https://github.com/dracula/visual-studio-code/blob/main/src/dracula.yml:
VSCode built in themes does not have it, like "Dark Modern":
tokenColorsfrom: https://github.com/microsoft/vscode/blob/main/extensions/theme-defaults/themes/dark_vs.jsonI think the fix should be to use a TextMate scope that is more common in VSCode themes.
This was suggested to me by Gemini Fast and worked in my testing with VSCode + Dark Modern theme:
support.constant.variable.powershell.variable.other.readwrite.constant.powershell.C# uses
variable.other.readwrite.cs:andyleejordan commentedon Apr 23, 2026
Did #223 resolve this?
RedCMD commentedon Apr 24, 2026
yup