Version

Indent / Outdent Lines (xamSyntaxEditor)

Topic Overview

Purpose

This topic provides information about indenting and outdenting text block as well as text formatting, which is based on rules defined by the language as well as the default (and optionally custom) IndentServiceProvider registered on the Language.

Required background

The following topics are prerequisites to understanding this topic:

Topic Purpose

In this topic, you will find information to help you better understand the xamSyntaxEditor’s functions.

This topic covers the text editing capabilities of the xamSyntaxEditor control from both the developer and user’s perspective.

Introduction

Overview

The xamSyntaxEditor™ supports the indenting/outdenting of text blocks as well as automatic indenting/outdenting applied by the default (and optionally custom) IndentServiceProvider registered by the Language.

Indenting and Outdenting Using Keyboard Shortcuts

Shortcuts summary chart

The user may indent/outdent selected text while editing a document using the following key combination:

Key (combination) Operation

Tab

Indent the text selection

Shift + Tab

Outdent the text selection

xamSyntaxEditor Indent1.png

Programmatic Indenting and Outdenting

Methods summary chart

You can use the following TextDocument methods to indent and outdent a specified range of contiguous lines.

Method Arguments Description
  • lineIndex

  • lineCount

This method will indent the specified number of lines starting from the line specified in lineIndex (zero-based index).

  • lineIndex

  • lineCount

This method will outdent the specified number of lines starting from the line specified in lineIndex (zero-based index).

Automatic Indenting and Outdenting

Description

Automatic indentation is based on The default (or optionally custom) IndentServiceProvider registered on the language. The indentation occurs automatically while editing text.

The screenshot below shows how the caret is automatically indented when the user presses the Enter key after a curly open braces, when the language is set to CSharpLanguage:

xamSyntaxEditor Indent2.png

Related Content

Topics

The following topics provide additional information related to this topic.

Topic Purpose

This topic lists the languages supported by the xamSyntaxEditor and shows you how to use each of them.