次の方法で共有


ITextBuffer.Replace(Span, String) Method

Definition

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.

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

Parameters

replaceSpan
Span

The span of characters to replace.

replaceWith
String

The new text to replace the old.

Returns

The ITextSnapshot.

Exceptions

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

replaceWithis null.

A text edit is currently active, or CheckEditAccess() would return false.

Remarks

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.

Applies to