Compartir a través de


Find2.FindReplace Method

Definition

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

EnvDTE::vsFindResult FindReplace(EnvDTE::vsFindAction Action, std::wstring const & FindWhat, int vsFindOptionsValue = 0, std::wstring const & ReplaceWith = "", EnvDTE::vsFindTarget Target = EnvDTE.vsFindTarget.vsFindTargetCurrentDocument, std::wstring const & SearchPath = "", std::wstring const & FilesOfType = "", EnvDTE::vsFindResultsLocation ResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1);
[System.Runtime.InteropServices.DispId(0)]
public EnvDTE.vsFindResult FindReplace (EnvDTE.vsFindAction Action, string FindWhat, int vsFindOptionsValue = 0, string ReplaceWith = "", EnvDTE.vsFindTarget Target = EnvDTE.vsFindTarget.vsFindTargetCurrentDocument, string SearchPath = "", string FilesOfType = "", EnvDTE.vsFindResultsLocation ResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1);
[<System.Runtime.InteropServices.DispId(0)>]
abstract member FindReplace : EnvDTE.vsFindAction * string * int * string * EnvDTE.vsFindTarget * string * string * EnvDTE.vsFindResultsLocation -> EnvDTE.vsFindResult
Public Function FindReplace (Action As vsFindAction, FindWhat As String, Optional vsFindOptionsValue As Integer = 0, Optional ReplaceWith As String = "", Optional Target As vsFindTarget = EnvDTE.vsFindTarget.vsFindTargetCurrentDocument, Optional SearchPath As String = "", Optional FilesOfType As String = "", Optional ResultsLocation As vsFindResultsLocation = EnvDTE.vsFindResultsLocation.vsFindResults1) As vsFindResult

Parameters

Action
vsFindAction

Required. A vsFindAction constant that indicates the search action to take.

FindWhat
String

Optional. The pattern to search for. The default is "".

vsFindOptionsValue
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
String

Optional. A string with which to replace the matched text when Action is set to vsFindActionReplace or vsFindActionReplaceAll. Default value is "".

Target
vsFindTarget

Optional. A vsFindTarget constant that indicates the target for the search operation, such as the current document or find-in-files.

SearchPath
String

Optional. A semicolon-separated list of directories and file names to search. The default value is "".

FilesOfType
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
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.

Returns

A vsFindResult constant.

Implements

Attributes

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  

Applies to