ITextEdit.Replace Method

Definition

Overloads

Replace(Span, String)

Replaces a sequence of characters with different text. This method has the same effect as first deleting the characters in replaceSpan and then inserting replaceWith.

Replace(Int32, Int32, String)

Replaces a sequence of characters with different text. This method has the same effect as first deleting the charsToReplace and then inserting replaceWith.

Replace(Span, String)

Replaces a sequence of characters with different text. This method has the same effect as first deleting the characters in replaceSpan and then inserting replaceWith.

public:
 bool Replace(Microsoft::VisualStudio::Text::Span replaceSpan, System::String ^ replaceWith);
public:
 bool Replace(Microsoft::VisualStudio::Text::Span replaceSpan, Platform::String ^ replaceWith);
bool Replace(Microsoft::VisualStudio::Text::Span replaceSpan, std::wstring const & replaceWith);
public bool Replace (Microsoft.VisualStudio.Text.Span replaceSpan, string replaceWith);
abstract member Replace : Microsoft.VisualStudio.Text.Span * string -> bool
Public Function Replace (replaceSpan As Span, replaceWith As String) As Boolean

Parameters

replaceSpan
Span

The span of characters to replace.

replaceWith
String

The new text.

Returns

true if the replacement succeeded, false if it was prevented by a read-only region.

Exceptions

The Apply() or Cancel() or Dispose() method has previously been called on this object.

replaceSpan.End is greater than the length of the buffer.

replaceWithis null.

Remarks

Replacing an empty span with an empty string will succeed but will not generate a new snapshot or raise a Changed event.

Applies to

Replace(Int32, Int32, String)

Replaces a sequence of characters with different text. This method has the same effect as first deleting the charsToReplace and then inserting replaceWith.

public:
 bool Replace(int startPosition, int charsToReplace, System::String ^ replaceWith);
public:
 bool Replace(int startPosition, int charsToReplace, Platform::String ^ replaceWith);
bool Replace(int startPosition, int charsToReplace, std::wstring const & replaceWith);
public bool Replace (int startPosition, int charsToReplace, string replaceWith);
abstract member Replace : int * int * string -> bool
Public Function Replace (startPosition As Integer, charsToReplace As Integer, replaceWith As String) As Boolean

Parameters

startPosition
Int32

The buffer position at which to start replacing.

charsToReplace
Int32

The number of characters to replace.

replaceWith
String

The new text.

Returns

true if the replacement succeeded; false if it was prevented by a read-only region.

Exceptions

The Apply() or Cancel() or Dispose() method has previously been called on this object.

startPosition is less than zero or greater than the length of the buffer, or charsToReplace is less than zero, or startPosition + charsToReplace is greater than the length of the buffer.

replaceWithis null.

Remarks

Replacing zero characters with an empty string will succeed but will not generate a new snapshot or raise a Changed event.

Applies to