Skip to content

Comment

Øyvind Kallstad edited this page Sep 7, 2017 · 5 revisions

Line comments

Line comments are comments that start with the hash-character (#) and ends with a line-break (EOL).

Example
# This is a line comment
Write-Host 'Hello World!' #This is also a line comment!

Scopes

The following scopes are assigned to line comments:

  • punctuation.definition.comment
  • comment.line

The hash-character is given the punctuation.definition.comment scope, while the comment itself are given the comment.line scope.

Block comments

Block comments start with <# and ends with #>. Everything between these two markers are considered a comment.

Example
<#
    This is a block comment.
#>

Scopes

The following scopes are assigned to block comments:

  • punctuation.definition.comment
  • comment.block

<# and #> are assigned the punctuation.definition.comment scope, and everything inbetween is given the comment.block scope.

Comment-based help

Within any comment scope, syntax highlighting rules exist for PowerShell comment-based help.

Example
<#
    .Description
        Get-Function displays the name and syntax of all functions in the session.
#>

Scopes

The following scopes are assigned to comment-based help:

  • keyword.operator.documentation
  • comment.block.documentation
  • constant.string.documentation

The keywords (.Description the above example) are given the scope of keyword.operator.documentation, while normal strings after the keyword (if on the same line) gets the constant.string.documentation scope. comment.block.documentation is a meta scope given to the whole line.

Home

About

Use

Contributing

Scopes and Tokens

Clone this wiki locally