Automatic formatting in a legacy language service

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

With automatic formatting, a language service automatically inserts a snippet of code when a user begins to type a known code construct.

Automatic formatting behavior

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.

See also