Visual Studio 2012: Find in Files Feature
This is the second post of a 30 post series that covers futures in Visual Studio 2012 and TFS 2012. Posts will range from beginner level to advance level.
You may want to read the post about the Quick Find feature first.
Find in Files
The Quick Find would be a slow option to find certain text if the matched text is repeated across too many files. In such a scenario, you are better off leveraging the Find in Files feature. The Find in files dialog comes equipped with a regular expression builder to assist in building a regular expression string.
There are three methods to launch the Find in Files dialog
1. Ctrl + Shift + F keyboard shortcut
2. EDIT —>Find and Replace —> Find in Files
3. From the Quick Find dialog, expand the search history and click on Find In Files … link
The Find and Replace Dialog looks as follows
1. Two tabs, Find in Files and Replace in Files, to toggle between the find and replace
2. The text or expression to find
4. The checkboxes has been explained in the Quick Find feature post. Notice when the “Use Regular Expressions is checked, the Expression builder button is enabled. The Loo at these file types drop down allows you to specify the file extensions of the files to be searched where blank is the same as *.*
5. List results in: specifies whether the search results displayed in “Find Results 1” or “Find Results 2” window
Display file names only: when unchecked, the Find Result window shows the name of the file, line number where a match exists and the line of text where the match is found
whereas when it is checked the Find Result window displays only the file name where the match is found
6. Find Previous and Find Next highlights the previous and next match respectively
7. Find All, find all matches for the search criteria and displays them in either the Find Result 1 or Find Result 2 Window
8. Bookmarks the lines of code where matches are found. It is like adding them to favorites to look at them later on
Choose Search folders
Clicking on the ellipsis button next to the Lookin combobox launches the following dialog
The dialog allows you select one or more folder to be added to the search scope in the find in files feature. By default the C: drive will be displayed in the number 1 list. Double click on the C:\ drive to dig down and list the folders within it. I kept opening folders until I got to the C:\Users\Ahmed\ directory and selected the My Document folder and then press the > button at 5. Alternatively, you can type C:\Users\Ahmed\ on the Available folders dropdown (4) and press enter then press the > button to move the folder to the Selected folders list
While I am in the the Ahmed folder, I am also selecting the Downloads folder
I want to save those folders as folder set to use it later if I wanted to. To do so, I named the folder set as Docs_Downloads and then clicked the Apply button. Then click the OK button to go back to the Find in Files dialog
Notice that the folder set is selected in the Look in drop down and the Include sub-folders is available (enabled).
I then tried to find the text “status” in the Docs_Downloads folder set and I got a list of matches in the files in both My Documents and Download folders.
While the search is running, you may want to stop it. To do so, press the Ctrl + Shift + F combination and then click the Stop Find button