In This Article

Indent Provider

An indent provider enables support for smart indent features when pressing ENTER.

The Indent Providers topic talks about indent providers in general and how to register them as a "feature" language service.

The CSharpIndentProvider class is the default implementation of an IIndentProvider service for this language.

Feature Summary

Smart Indent

The built-in indent provider will attempt to properly indent lines inside the current block scope. For instance, pressing ENTER after a { will cause the next line to be indented by one tab stop. Pressing ENTER while still typing a statement will also attempt to indent the next line by one tab stop.

Typed Characters

When certain characters such as {, }, or : are typed, the line will be examined to see if it should be indented/outdented.

Registering with a Syntax Language

Any object that implements IIndentProvider can be associated with a syntax language by registering it as an IIndentProvider service on the language.

The CSharpSyntaxLanguage class automatically registers a CSharpIndentProvider with itself when it is created, so normally indent providers never need to be set on a C# language unless a custom one is made.

This code creates a custom indent provider (defined in a make-believe CustomCSharpIndentProvider class) and registers it with the syntax language that is already declared in the language variable:

language.RegisterIndentProvider(new CustomCSharpIndentProvider());
Note

The SyntaxLanguageExtensions.RegisterIndentProvider method in the code snippet above is a helper extension method that gets added to ISyntaxLanguage objects when the ActiproSoftware.Text namespace is imported. See the Service Locator Architecture topic for details on registering and retrieving various service object instances, both via extension methods and generically, as there are some additional requirements for using the extension methods.

Disabling the Functionality

Since this feature is installed as a "feature" service on the language and is installed on CSharpSyntaxLanguage by default, it can be disabled by uninstalling the service from the language.