Visual Studio Tip: Dude, Where's My File?

When you do a Find in Files (CTRL+SHIFT+F), by default the output displays the file path which can fill up the results window. Did you know you can use a registry key to customize the output of your search?
Just create a string value in the registry called "Find result format" put it in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\Find (12.0 for VS 2013, 11.0 for VS2012, 10.0 for VS2010) then specify a value for your new registry string value of $f$e($l,$c):$t\r\n This will display file name file extension (line number column number): line of code containing the string match and then inserts a carriage return.
The end result? Simpler search results (as long as you don't need the file path)
Awesome!
Is there a way to only get a part of the path from the solution root folder?
eg
C:\Data\Projects\Projectname\Solutionname\Controllers\AccountController.cs
becomes
Controllers\AccountController.cs
Cool. This really does need to go on the options dialog.
One question (without trying it): does this mean you can't click on the path to open the file? Because if that still works, then it's the best thing ever. If not then I'd (personally) keep the need to scroll to the right if it means I can open the file.
Hi,
Thank you. Very useful.
Can we apply the same tip to "Find Symbol Results" - ctrl+k+r ? If so, can you please tell me what will be the correspondent Folder for the action "Find Symbol Results"?
Thanks!
JohnLudlow, yes, you can still click to open the file.
If you prefer a PowerShell script:
Set-ItemProperty HKCU:\Software\Microsoft\VisualStudio\12.0\Find -Name 'Find result format' -Type String -Value '$f$e($l,$c):$t\r\n'
-Jon Tims [MSFT]
@JonTims: Sweet
Yeah the PowerShell script is better for copy-past-iness.
And yes, @dudumanbogdanvlad raises a good point that this would be useful in the Find Symbol / Find References windows
BTW, I found this blog post which explains what the different specifiers mean:
This is the format I've started using:
$f$e($l,$c):\t\t\t$s\r\n
It's mostly the same, but I've added some tabs to separate the file name from the match, and used $s instead of $t because it seems to trim out any leading spaces from the match. This (IMHO) leads to a more regular list of matches which is less randomly spaced.
Thanks for the tip
You guys are off and running with this! Thanks for sharing the powershell script!
Very helpful. Thank you for posting.