Tuesday, December 11, 2007

Customize your Find in Files Results in Visual Studio

Customize your Find in Files Results in Visual Studio :

The default find in files results window of Visual Studio provides you only File name and line number with in the braces along with the code text. You can customize these results to show what you want to see and how you want to see it. If you spend a lot of your time in reformatting these results for any purpose then this tip might be helpful for you in doing so.

To display Find in files results view in a different format you need to add a registry setting under:
HKEY_CURRENT-USER\Software\Microsoft\VisualStudio\8.0\Find.
Following registry setting will display Find in files results in the below format:
Directory: {Name of the directory}
File Name: {Name of the file}
Line#: {Line number}
Code: {Code snippet}

  1. Go to HKEY_CURRENT-USER\Software\Microsoft\VisualStudio\8.0\Find
  2. Add a new string value called Find result format with a value of Directory : $d\nFile Name : $f$e\nLine #: $l\nCode:$t\r\n where
$d is directory name
$f is the filename
$e is the extension
$l is the line
$t is the text on the line

Note: You don’t have to restart Visual Studio to pick up on your registry changes.

Example Results after the above Registry setting:

Find all "[assembly: AssemblyCulture("")]", Whole word, Subfolders, Find Results 1, "c:\poroj\Source Code\PList", "*.*"
Directory : c:\poroj \Source Code \PList\Business Logic\
File name : AssemblyInfo.cs
Line #: 15
Code:[assembly: AssemblyCulture("")]
Directory : c:\poroj \Source Code \PList\Business Logic\Properties\
File name : AssemblyInfo.cs
Line #: 15
Code:[assembly: AssemblyCulture("")]

Even you can erase or modify the previously typed in search strings in the "Look in" combo on the "Find in Files" search toolbar. This can be done by modifying or erasing previously typed in search string values at HKEY_CURRENT-USER\Software\Microsoft\VisualStudio\8.0\Find, this cannot be possible through the Visual Studio UI.













Full list of items you can specify in the registry:
FilesLocationTextChar
$pPath$lline$0Matched text\nNew line
$f File name$cCol$tText of first line\sSpace
$vDrive/Unc name$xend column if on first line, else end of first line$sSummary of hit\tTab
$dDirectory name$Lspan end line$TText of spanned lines\\Slash
$nName$Cspan end column\$$
$eFile extension

Add to Technorati Favorites