5.2. Find in Files

The really powerful part of the search engine built into Visual Studio is found in the Find in Files command. Rather than restrict yourself to a single document or project, Find in Files gives you the ability to search entire folders (along with all their sub-folders), looking for files that contain the search criteria.

The Find in Files dialog, shown in Figure 5-7, can be invoked via the menu command Edit Find and Replace Find in Files. Alternatively, if you have the Quick Find dialog open, you can switch over to Find in Files mode by clicking the small drop-down arrow next to Quick Find and choosing Find in Files. You can also use the keyboard shortcut Ctrl+Shift+F to launch this dialog.

Figure 5.7. Figure 5-7

Most of the Quick Find options are still available to you, including wildcard and regular expressions searching, but instead of choosing a scope from the project or solution, you use the "Look in" field to specify where the search is to be performed. Either type the location you wish to search or click the ellipsis to display the Choose Search Folders dialog, shown in Figure 5-8.

Figure 5.8. Figure 5-8

You can navigate through the entire file system, including networked drives, and add the folders you want to the search scope. This enables you to add disparate folder hierarchies to the one single search. Start by using the "Available folders" list on the left to select the folder(s) that you would like to search. Add them to the "Selected folders" list by clicking the right arrow. Within this list you can adjust the search order using the up and down arrows. Once you have added folders to the search, you can simply click "OK" to return a semicolon-delimited list of folders. If you want to save this set of folders for future use you can enter a name into the "Folder set" drop-down and click "Apply."

The process of saving search folders is less than intuitive, but if you think of the "Apply" button as more of a save button then you can make sense of this dialog.

5.2.1. Find Dialog Options

Because the search is being performed on files that are not normally open within the IDE, the two Find options normally used for open files — namely, "Search up" and "Search hidden text" — are not present. However, in their place is a filter that can be used to search only on specific file types.

The Look at These File Types drop-down list contains several extension sets, each associated with a particular language, making it easy to search for code in Visual Basic, C#, J#, and other languages. You can type in your own extensions too, so if you're working in a non-Microsoft language, or just want to use the Find in Files feature for non-development purposes, you can still limit the search results to those that correspond to the file types you want.

In addition to the Find options, there are also configuration settings for how the results will be displayed. For searching you can choose one of two results windows, which enables you to perform a subsequent search without losing your initial action. The results can be quite lengthy if you show the full output of the search, but if you're interested only in finding out which files contain the information you're looking for, check the Display Filenames Only option and the results window will be populated with only one line per file.

5.2.2. Results Window

When you perform a Find in Files action, results are displayed in one of two Find Results windows. These appear as open tool windows docked to the bottom of the IDE workspace. For each line that contained the search criteria, the results window displays a full line of information, containing the filename and path, the line number that contained the match, and the actual line of text itself, so you can instantly see the context (see Figure 5-9).

Figure 5.9. Figure 5-9

Along the top of each results window is a small Toolbar, as shown in Figure 5-10 (left), for navigation within the results themselves. These commands are also accessible through a context menu, as shown in Figure 5-10 (right).

Figure 5.10. Figure 5-10

Right-click the particular match you want to look at and choose the Go To Location command. Alternatively, double-click a specific match.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.168.211