ITextBuffer::Replace Method (Span, String^)
Visual Studio 2015
Replaces a sequence of characters with different text. This is equivalent to first deleting the text to be replaced and then inserting the new text.
Assembly: Microsoft.VisualStudio.Text.Data (in Microsoft.VisualStudio.Text.Data.dll)
Parameters
- replaceSpan
-
Type:
Microsoft.VisualStudio.Text::Span
The span of characters to replace.
- replaceWith
-
Type:
System::String^
The new text to replace the old.
| Exception | Condition |
|---|---|
| ArgumentNullException | replaceWith is null. |
| InvalidOperationException | A text edit is currently active. |
| ArgumentOutOfRangeException | replaceSpan.End is greater than the length of the buffer. |
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.
Show: