다음을 통해 공유


Find 인터페이스

업데이트: 2007년 11월

IDE에서 문서와 파일에 대한 일반적인 텍스트 Find 작업을 지원합니다.

네임스페이스:  EnvDTE
어셈블리:  EnvDTE(EnvDTE.dll)

구문

<GuidAttribute("40D4B9B6-739B-4965-8D65-692AEC692266")> _
Public Interface Find

Dim instance As Find
[GuidAttribute("40D4B9B6-739B-4965-8D65-692AEC692266")]
public interface Find
[GuidAttribute(L"40D4B9B6-739B-4965-8D65-692AEC692266")]
public interface class Find
public interface Find

설명

Find 개체를 사용하면 코드 편집기와 같이 이러한 작업을 지원하는 환경에서 텍스트를 검색하고 바꿀 수 있습니다.

이 방법은 주로 매크로 기록에 사용됩니다. 편집기의 매크로 기록 메커니즘에서는 전역 찾기 기능을 활용할 수 있도록 TextSelection.FindPattern 대신 Find를 사용합니다. 또한 파일에서 찾기 같은 작업을 수행할 때는 일반적으로 TextSelection 개체보다 이 개체가 유용합니다.

Visual Studio 환경의 전역 찾기 상태는 검색 기능을 제공하는 모든 도구에서 공유됩니다. 예를 들어 모든 Visual Studio 요소에서는 세션 중에 사용된 검색 패턴 목록 및 열린 문서에서 다음 Find 작업을 수행할 때 적용할 검색 방향(앞으로 또는 뒤로) 등을 공유합니다. Find 개체의 속성은 전역 찾기 상태와 상호 작용하면서 상태를 추적합니다. Find 개체에 속성을 설정할 때 전역 찾기 상태도 설정됩니다. 사용자가 전체 환경에서 Find 작업을 수행하면 적용된 검색 유형이 Find 개체에 반영됩니다. 자동화 코드는 환경의 UI 스레드와 동기적으로 실행되므로 일부 속성을 설정할 필요가 없으며 Execute를 호출하기 전에 사용자가 검색 작업을 수행하지 않아도 됩니다.

Execute 메서드는 Find 개체의 설정에 따라 Find 작업을 수행합니다. 또한 FindReplace 메서드에 인수를 전달하여 전역 찾기 상태에 영향을 주지 않고 검색을 수행할 수도 있습니다. 자동화 클라이언트에서는 전역 찾기 상태에 영향을 주지 않거나 환경 상태의 최종 사용자 모델을 방해하지 않고 검색을 수행할 수 있어야 합니다.

예제

Sub FindExample()
   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

   ' Set the find options.
   objFind.Action = vsFindAction.vsFindActionReplaceAll
   objFind.Backwards = False
   objFind.FilesOfType = "*.txt"
   objFind.FindWhat = "test"
   objFind.KeepModifiedDocumentsOpen = True
   objFind.MatchCase = False
   objFind.MatchInHiddenText = False
   objFind.MatchWholeWord = True
   objFind.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
   objFind.ReplaceWith = "NEW THING"
   objFind.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
   objFind.SearchPath = "c:\temp"
   objFind.SearchSubfolders = False
   objFind.Target = vsFindTarget.vsFindTargetCurrentDocument
   ' Perform the Find operation.
   objFind.Execute()
End Sub

참고 항목

참조

Find 멤버

EnvDTE 네임스페이스