0

Ive been scratching my head with this one. Previously VS Code highlighted Powershell scripts and modules just fine with highlighting functions in yellow and variables $var in light blue. Both as part of a string and "stand-alone". However, suddenly it doesn't highlight functions or variables anymore? I've tried to uninstall and reinstall the powershell extension from Microsoft, as well as disable and re-enable the built in language support for powershell.

I've not been able to find any support regarding this issue and hope that I might be able to find it here.

Peter
  • 21
  • 2

3 Answers3

1

Have you tried this? File Association.

Basically:

The easiest way I've found for a global association is simply to Ctrl+k m (or Ctrl+Shift+P and type "change language mode") with a file of the type you're associating open.

In the first selections will be the option "Configure File Association for 'x' " (whatever file type - see image attached). Selecting this gives you the option to choose the language and will then make the filetype association permanent.

marek1712
  • 11
  • 1
  • Hi! Thanks for replying! I've tried to associate the .psm1 and ps files with powershell language but that does not seem to solve the issue. The syntax highlighting sort of works allready but not for variables and for functions. I Found myself a workaround today with simply running the VS Code insiders cause the highlighting worked great there. It also works great on some other servers I'm running using VS code. Right now it seems like the easiest workaround is to just reinstall vscode but that seems unproductive :O – Peter Dec 10 '21 at 17:16
1

Change the color theme to Dark+. I had the same question and the root of it was that I accidentally changed the theme to Dark (Visual Studio).

0

if you start your code block with a ```PowerShell it will highlight the syntax properly.

I've noticed that you may also need to end your code block with a ``` in VSCode specifically.

Josh
  • 1
  • 1