This topic has not yet been rated - Rate this topic

IProjectionBufferBase.Replace Method

Replaces a span of characters with different text. This is equivalent to first deleting the text to be replaced and then inserting the new text.

Namespace:  Microsoft.VisualStudio.Text.Projection
Assembly:  Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)
IProjectionSnapshot Replace(
	Span replaceSpan,
	string replaceWith
)

Parameters

replaceSpan
Type: Microsoft.VisualStudio.Text.Span

The span of characters to replace.

replaceWith
Type: String

The new text.

ExceptionCondition
ArgumentNullException

replaceWith is null.

ArgumentOutOfRangeException

The end of replaceSpan span is greater than the length of the buffer.

InvalidOperationException

A ITextEdit is currently active.

This is a shortcut for creating a new ITextEdit object, using it to replace the text, and then applying it. If the replacement fails on account of a read-only region, the snapshot returned will be the same as the current snapshot of the buffer before the attempted replacement.

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.