共用方式為


ProvideLanguageServiceAttribute.EnableFormatSelection Property

Definition

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

public:
 property bool EnableFormatSelection { bool get(); void set(bool value); };
public:
 property bool EnableFormatSelection { bool get(); void set(bool value); };
public bool EnableFormatSelection { get; set; }
member this.EnableFormatSelection : bool with get, set
Public Property EnableFormatSelection As Boolean

Property Value

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

Examples

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

Remarks

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  

Applies to