You are on page 1of 2

Searching with Find and Replace

Visual Studio provides extensive Find and Replace capabilities that go way beyond what you find in a standard text editor. Table 1-2 lists the Find and Replace options. You access the Find and Replace commands by choosing Edit Find and Replace or by using keyboard shortcuts.

Table 1-2 Find and Replace Commands

Command Keyboard Shortcut Purpose Quick Find Ctrl+F Searches for text Quick Replace Ctrl+H Replaces text Find in Files Ctrl+Shift+F Includes options for searching for text in a set of files Replace in Files Ctrl+Shift+H Includes options for replacing text in a set of files Find Symbol Alt+F12 Restricts search scope to symbols only The Find and Replace commands all use the same dialog box, and most of the commands use the same options. As Figure 1-4 shows, your Find and Replace options are the following:  Find What: In this text box, enter text for which to search.  Replace With: In this text box, enter text to replace the found text.  Look In: From this drop-down list, specify the scope of the search, such as Current Document or Entire Solution.


Using the Code Editor

Figure 1-4: Use Find and Replace commands to search your code.

 Find Options: Use these checkboxes to specify options, such as whether to match case or the whole word.  Find Next: Click this button to find the next text match. The button toggles to Replace Next when you are in Replace mode.  Replace All: Clicking this button replaces all matches. The button toggles to Find All when you are in Find mode. To select a different kind of Find and Replace command, open the drop-down lists displayed at the top of the Find and Replace dialog box. Before you use Find and Replace, ask yourself whether one of the Visual Studio new refactoring features might work better. See Chapter 5 of Book III for an overview of refactoring in Visual Studio. The Find Symbols command restricts your search to only symbols. Symbols are the methods and type definitions declared in source code. You can use the Find Symbols command to search your own code or external libraries for which you don’t have source code. The results of the Find Symbols code appear in the Find Symbol Results window. Figure 1-5 shows the results from a search for BeginSend in a set of source code. The results show exactly where BeginSend is used in source code. Double-click any of the results to go to the source code.
Book III Chapter 1

Programming with Visual Studio 2010

Using the Code Editor


.Figure 1-5: The Find Symbol Results window displays all the instances where the text appears in symbols.