Find.FindReplace Method

Performs a Find or Replacement operation based on the arguments to the method, without affecting the options set for the Find.

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.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

  • FindWhat
    Type: System.String

    Optional. The pattern to search for. The default 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 "", meaning all files are searched.

  • ResultsLocation
    Type: EnvDTE.vsFindResultsLocation

    Optional. A vsFindResultsLocation constant. There are two possible results 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.

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

See Also

Reference

Find Interface

EnvDTE Namespace