Share via


Source.UncommentSpan Method

Removes any comment characters from the beginning and end of the given span.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaration
Public Overridable Function UncommentSpan ( _
    span As TextSpan _
) As TextSpan
public virtual TextSpan UncommentSpan(
    TextSpan span
)
public:
virtual TextSpan UncommentSpan(
    TextSpan span
)
abstract UncommentSpan : 
        span:TextSpan -> TextSpan  
override UncommentSpan : 
        span:TextSpan -> TextSpan
public function UncommentSpan(
    span : TextSpan
) : TextSpan

Parameters

Return Value

Type: Microsoft.VisualStudio.TextManager.Interop.TextSpan
A new TextSpan object describing the span after the comment characters have been removed.

Remarks

This method determines how best to uncomment the span by deciding between line and block comments, and then calls the UncommentBlock method or the UncommentLines method on the span. Call the GetCommentFormat method to obtain the strings that define a comment.

The base method calls the GetCommentFormat method, and then calls the UncommentLines method if the line comment string is specified; otherwise, this method calls the TrimSpan method to eliminate leading and trailing whitespace and then calls the UncommentBlock method if the block comment strings are specified. Note that this approach always favors removing line comments if both line comment and block comment strings are specified -- even when uncommenting a block of text. Also, the base method cannot handle a mix of block and line comments in the span.

This method is typically called in response to the user selecting the command Uncomment Selection from the Advanced menu on the Edit menu.

Commenting Code (Managed Package Framework) for more information about how this method is called.

.NET Framework Security

See Also

Reference

Source Class

Microsoft.VisualStudio.Package Namespace

Other Resources

Commenting Code (Managed Package Framework)