Find2.FindReplace Method
Performs a Find or Replace operation based on the arguments to the method, without affecting the options set for the Find object.
Namespace: EnvDTE80
Assembly: EnvDTE80 (in EnvDTE80.dll)
Syntax
'Declaration
Function FindReplace ( _
Action As vsFindAction, _
FindWhat As String, _
vsFindOptionsValue As Integer, _
ReplaceWith As String, _
Target As vsFindTarget, _
SearchPath As String, _
FilesOfType As String, _
ResultsLocation As vsFindResultsLocation _
) As vsFindResult
vsFindResult FindReplace(
vsFindAction Action,
string FindWhat,
int vsFindOptionsValue,
string ReplaceWith,
vsFindTarget Target,
string SearchPath,
string FilesOfType,
vsFindResultsLocation ResultsLocation
)
vsFindResult FindReplace(
[InAttribute] vsFindAction Action,
[InAttribute] String^ FindWhat,
[InAttribute] int vsFindOptionsValue,
[InAttribute] String^ ReplaceWith,
[InAttribute] vsFindTarget Target,
[InAttribute] String^ SearchPath,
[InAttribute] String^ FilesOfType,
[InAttribute] vsFindResultsLocation ResultsLocation
)
abstract FindReplace :
Action:vsFindAction *
FindWhat:string *
vsFindOptionsValue:int *
ReplaceWith:string *
Target:vsFindTarget *
SearchPath:string *
FilesOfType:string *
ResultsLocation:vsFindResultsLocation -> vsFindResult
function FindReplace(
Action : vsFindAction,
FindWhat : String,
vsFindOptionsValue : int,
ReplaceWith : String,
Target : vsFindTarget,
SearchPath : String,
FilesOfType : String,
ResultsLocation : vsFindResultsLocation
) : vsFindResult
Parameters
- Action
Type: EnvDTE.vsFindAction
Required. A vsFindAction constant that indicates the search action to take.
- FindWhat
Type: System.String
Optional. The pattern to search for. The default is "".
- vsFindOptionsValue
Type: System.Int32
Optional. A bit field indicating several aspects of the search to perform.
For matching, you can supply vsFindOptionsMatchCase, vsFindOptionsMatchWholeWord, or vsFindOptionsMatchInHiddenText.
Flags that can be turned on for files, project, and solution targets are vsFindOptionsSearchSubfolders and vsFindOptionsKeepModifiedDocumentsOpen.
Flags for the FindWhat property syntax are vsFindOptionsRegularExpression and vsFindOptionsWildcards. If neither is supplied, then FindWhat is matched literally.
vsFindOptionsValue defaults to all flags turned off.
- ReplaceWith
Type: System.String
Optional. A string with which to replace the matched text when Action is set to vsFindActionReplace or vsFindActionReplaceAll. Default value is "".
- Target
Type: EnvDTE.vsFindTarget
Optional. A vsFindTarget constant that indicates the target for the search operation, such as the current document or find-in-files.
- SearchPath
Type: System.String
Optional. A semicolon-separated list of directories and file names to search. The default value is "".
- FilesOfType
Type: System.String
Optional. A semicolon-separated list of file types to include in the search. Other file types encountered in the specified targets are ignored. The default value is "", which means that all files are searched.
- ResultsLocation
Type: EnvDTE.vsFindResultsLocation
Optional. A vsFindResultsLocation constant. There are two possible result lists where Find results can display. You can perform two searches without overwriting the results of the first search. Using ResultsLocation, you can determine the result list in which to place the Find results.
Return Value
Type: EnvDTE.vsFindResult
A vsFindResult constant.
Implements
Examples
Sub FindReplaceExample()
Dim objTextDoc As TextDocument
Dim objEditPt As EditPoint
Dim iCtr As Integer
Dim objFind As Find
' Create a new text file.
DTE.ItemOperations.NewFile("General\Text File")
' Get a handle to the new document and create an EditPoint.
objTextDoc = DTE.ActiveDocument.Object("TextDocument")
objEditPt = objTextDoc.StartPoint.CreateEditPoint
objFind = objTextDoc.DTE.Find
' Insert ten lines of text.
For iCtr = 1 To 10
objEditPt.Insert("This is a test." & Chr(13))
Next iCtr
objEditPt.StartOfDocument()
objFind.FindReplace(vsFindAction.vsFindActionReplaceAll, "test", vsFindOptions.vsFindOptionsMatchWholeWord, "NEW THING", vsFindTarget.vsFindTargetOpenDocuments, , , vsFindResultsLocation.vsFindResultsNone)
End Sub
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.