Share via


Did you know… You can customize how search results are displayed in the Find Results window? - #363

Argh! I wish I had found this one in time for the book. A second edition, maybe? I’d hate to be known as a one-hit wonder. I’m sure there are more people who could use scholarship money.

Ever did a Find in Files and was annoyed that Visual Studio showed the entire file path, forcing you to scroll over just to see the name of the file and the search result?

Find Results 1 before registry change

Here’s what you can do, among some other tweaks. Note: These involve modifying registry settings. Please use at your own risk! Also Note:  You don’t have to restart Visual Studio to pick up on your registry changes. Sweet!!!

  1. Go to HKCU\Software\Microsoft\VisualStudio\9.0\Find
  2. Add a new string called Find result format with a value of $f$e($l,$c):$t\r\n where

$f is the filename

$e is the extension

$l is the line

$c is the column

$t is the text on the line

Now let’s take a look at that Find Results window again:

Find Results 1 after registry change

And here’s the full list of items you can specify in the registry

Files

$p      path                       

$f      filename               

$v      drive/unc share            

$d      dir                        

$n      name                       

$e      .ext                       

Location

$l      line                       

$c      col                        

$x      end col if on first line, else end of first line

$L      span end line

$C      span end col

Text

$0      matched text               

$t      text of first line

$s      summary of hit

$T      text of spanned lines

Char

\n      newline                   

\s      space                     

\t      tab                       

\\      slash                    

\$      $                         

If you come up with a great combination of values, please leave a comment and share with the group!

Comments

  • Anonymous
    November 23, 2008
    PingBack from http://blog.a-foton.ru/index.php/2008/11/24/did-you-know%e2%80%a6-you-can-customize-how-search-results-are-displayed-in-the-find-results-window-363/

  • Anonymous
    November 23, 2008
    Now if we can get it so that Search Entire Project doesn't go through the generated xml files or Search All Open Documents only searched the opened documents...

  • Anonymous
    November 24, 2008
    This is possibly one of the most excellent VS Tips ever. Thanks! :-)

  • Anonymous
    November 24, 2008
    Hey! this one is really good!!! I´m really annoyed with this "entire file path" format in the find results window. But not anymore!!! Thanks to you, Sara!!!

  • Anonymous
    November 24, 2008
    The comment has been removed

  • Anonymous
    November 24, 2008
    Sweet! Secret registry ninja powers! Go Sara Go!

  • Anonymous
    November 24, 2008
    Really hard stuff for today! More like this!

  • Anonymous
    November 25, 2008
    Now, is there any way to get a relative path working? (ArtifactsMyArtifact.cs rather than C:blahblahblah...ArtifactsMyArtifact.cs or just MyArtifact.cs?

  • Anonymous
    November 25, 2008
    This is a great one. All my paths are several layers deep. Now it is only one dir deep. :) Question: Can you put any RegEx in? I was thinking that I might want the last portion of the directory plus the filename. Instead of: c:projectsSolutionDirProjDirFilename.cs(x,y): blah, blah, blah. I would rather see: ProjDirFilename.cs(x,y): blah, blah, blah. Any comments/suggestions?

  • Anonymous
    November 25, 2008
    Great one! Works prefect! Is there anyway to do the same for "Find Symbol Results" for "Find all references"? I tried to add a simular key "Find symbol format" and also "Find reference format", but nothing happend.

  • Anonymous
    November 26, 2008
    Thank You!!!  Best. Tip. Ever!

  • Anonymous
    November 30, 2008
    Excellent feature!  Thanks Sara! Mahendran Shanmugham

  • Anonymous
    December 03, 2008
    I cannot believe this is not exposed somewhere!  What a missed opportunity for a huge potential added value.

  • Anonymous
    December 05, 2008
    The comment has been removed

  • Anonymous
    January 05, 2009
    Wonderful!  Thank-you. This also works on Express versions but the registry keys are different, e.g. for Visual C# 2008 Express it is HKCUSoftwareMicrosoftVCSExpress9.0Find

  • Anonymous
    April 09, 2009
    本篇包括tip361-tip370http://www.watch-life.net/visual-studio/visual-studio-2008-tip-day-36.html#361、按...

  • Anonymous
    May 27, 2009
    Tip #0 Know your Keybindings! General Development Settings Searching Tips Tip #1 How to behold the power