Automatic Formatting in a Legacy Language Service
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at Automatic Formatting in a Legacy Language Service.
With automatic formatting, a language service automatically inserts a snippet of code when a user begins to type a known code construct.
For example, when you type if, the language service automatically inserts matching braces, or if you press the ENTER key, the language service forces the insertion point on the new line to the appropriate indent level, depending on whether the preceding line opens up a new scope.
The command filter used for the rest of the language service can also be used for automatic formatting. You can also highlight matching braces by calling HighlightMatchingBrace.