ProvideLanguageServiceAttribute.EnableFormatSelection Property

 

Determines if the language service supports automatic formatting of the source code.

Namespace:   Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.14.0 (in Microsoft.VisualStudio.Shell.14.0.dll)

public bool EnableFormatSelection { get; set; }

Property Value

Type: System.Boolean

Returns true if formatting is supported; otherwise, returns false.

A language service can support formatting source code which enhances the readability of the code. Formatting typically involves inserting white space at the beginning of each line to move it to the proper level of indentation. This formatting can occur when the user selects a command (Edit -> Advanced -> Format Selection or Edit -> Advanced -> Format Document) or it can be triggered automatically within the language service when a particular character is typed (for example, in C#, typing a closing brace '}' causes all the source between it and the corresponding opening brace '{' to be properly indented). The EnableFormatSelection property applies to any formatting.

This property is specific to the managed package framework (MPF).

The default is false when the corresponding registry entry is accessed through the LanguagePreferences class.

The registry entry looks like this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\[X.Y]\Languages\Language Services\
  [Language Name]\
    EnableFormatSelection = reg_dword: 0x00000001

[ProvideLanguageService(typeof(MyLanguageService),           // Required
                        MyConstants.languageName,            // Required
                        MyConstants.languageNameResourceID,  // Required
    // Optional language service properties
    EnableFormatSelection = true,  // formatting is supported
                       )]
Return to top
Show: