In This Article

Word Wrap

Word wrapping is a powerful feature that allows users to view all text for a line by wrapping text that normally would have been outside the view horizontally to one or more view lines in the editor.

Word Wrap Modes

The SyntaxEditor.WordWrapMode property can be set to WordWrapMode.Word to activate word wrap functionality. By default, it is set to WordWrapMode.None, meaning no word wrap.

Screenshot

Word wrap active in the editor, with the glyphs on the right indicating wrapped lines

This code activates word wrap:

editor.WordWrapMode = WordWrapMode.Word;

The boolean SyntaxEditor.IsWordWrapEnabled property also toggles between the WordWrapMode.None and WordWrapMode.Word wrap modes.

When the SyntaxEditor.WordWrapMode property is changed, the SyntaxEditor.WordWrapModeChanged event is raised.

Horizontal ScrollBar Visibility

The horizontal ScrollBar remains visible when word wrap is enabled and the SyntaxEditor.HorizontalScrollBarVisibility property has its default value of HorizontalScrollBarVisibility.Visible. The reason is that some platforms allow tray content next to the horizontal ScrollBar that may include buttons or caret position information, such as in Visual Studio's editor.

Some usage scenarios may wish to hide the horizontal ScrollBar when word wrap is enabled. This behavior can be achieved by handling the SyntaxEditor.WordWrapModeChanged event and altering the SyntaxEditor.HorizontalScrollBarVisibility property in response like this:

private void OnSyntaxEditorWordWrapModeChanged(object sender, EventArgs e) {
	editor.HorizontalScrollBarVisibility = (editor.WordWrapMode == WordWrapMode.None ? ScrollBarVisibility.Visible : ScrollBarVisibility.Auto);
}

Word Wrap Glyph Margin

Word wrap glyphs can be displayed on the right side of view lines in a special margin that indicate soft line breaks (wrapped lines).

The SyntaxEditor.AreWordWrapGlyphsVisible property can be set to true to activate this functionality.

Wrapped Line Indent Amount

By default, wrapped lines are indented by a configurable amount, relative to their primary line's indentation. The SyntaxEditor.WrappedLineIndentAmount property is what determines the indent amount of wrapped lines.

A value of 2 (the default) will indent wrapped lines to the original indent level of the primary line, plus 2 additional character widths. A value of 0 will indent wrapped lines to the original indent level of the primary line. A value of -1 will not indent wrapped lines at all and will simply align them to the left edge of the view.

The indent amount may be limited or altogether disabled if there is not enough available width in the view to support proper indentation.