Home > Net >  How can I colour Write-Debug and Write-Verbose a specific colour in VS Code?
How can I colour Write-Debug and Write-Verbose a specific colour in VS Code?

Time:10-16

I have a simple aim here but the execution seems relatively complex. All I would like to do is format Write-Debug and Write-Verbose anywhere they appear as the first text in a line (sometimes indented but no characters in front of them).

I would like to format them the same colour as my comments (or just manually setting them to the same colour is fine). Potentially I might want the same formatting for the rest of the line but that is optional.

I have done a quick google but the depth on the answers seems a lot to get my head around for something so simple, hoping somebody can help simplify it!

Thanks in advance.

CodePudding user response:

You can do this with the highlight powershell syntax


To highlight the whole line use:

"((^\\s*Write-Debug.*)|(Write-Verbose.*))": {

the text has to be in a capture group to be decorated. You could put the rest of the line into a different capture group if you wanted to decorate it differently.

  • Related