次の方法で共有


Customize how Find in Files results are displayed in the Find Results Window

Keyboard:  CTRL + SHIFT + F
Menu:  Edit -> Find and Replace -> Find in Files
Command:  Edit.FindinFiles
Versions:  2008,2010
Published: 1/3/2010
Code:  vstipFind0002 

   

image

 

You can customize your Find in Files results to show what you want to see and how you want to see it.

Example:  You don't want to view the entire file path shown in the Find Results tool window.

So instead of this:

image

 

 

You want this:

image

 

No problem! :)

 

DANGER:  This involves hacking the Registry so use this tip at your own risk!

  1. Open up RegEdit

  2. Go to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0\Find

  3. Add a new string called Find result format with a value of $f$e($l,$c):$t\r\n

    image

  4. Hop into Visual Studio and run a Find in Files search (NOTE: You do not need to restart VS to see the changes made in the Registry, which is great for testing different string combos)

 

Here are valid values you can use in the string:

 

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                    

\$      $

Comments

  • Anonymous
    January 09, 2010
    Great tip, works beautifully in VS2008 ! FYI, discovered this blog by searching for "visual studio" rss feeds on my.yahoo.com

  • Anonymous
    January 14, 2010
    The problem with this is that $d gives you the entire directory path (minus the device). So, your choice is between no directory information, or the entire dir path. What people with multiple projects would want is JUST THE LAST FOLDER of the directory path (the actual project folder). That is, the folder containing the file, as well as the file. So what is needed is a way to substring the $d value. I tried "$d[74]" (to start with the 74th character). Put it just appended "[74]" to the path string. Not terribly useful. Maybe some brilliant soul can figure out how to substring $d string. THEN this would really be useful!

  • Anonymous
    October 29, 2010
    Great tip Zain - will really come in handy when using VS on a laptop screen.

  • Anonymous
    July 15, 2011
    While it's changed slightly for 2010, this is plagiarized from saraford.net/.../customize-your-find-in-files-results-experience

  • Anonymous
    July 15, 2011
    Anonymous :) Actually it's taken directly from Sara's previous work.  Sara turned over the Tips to me and we are, in fact, writing a book together on the topics as well.  Just FYI. Z

  • Anonymous
    September 27, 2011
    Can you do the same for the "Bookmarks" window?   The "File Location" field can get very long, especially if you have your project/source in a sub-directory of your "My Documents". MSVS 2010 Pro Sorry if repeated

  • Anonymous
    November 21, 2011
    PATH ->$prnRESULTS ->$f$e($l,$c):$trnrn

  • Anonymous
    November 21, 2011
    DAC :) Sadly, no.  I am not aware of any other tool window that has this level of control.   Z

  • Anonymous
    November 21, 2011
    ca martin, cool!  I'll try it. :) Z

  • Anonymous
    December 28, 2011
    Is there any way to sort the results?

  • Anonymous
    February 07, 2012
    Aquaren :) Not that I am aware of short of putting them into Excel or some other tool. Z

  • Anonymous
    December 15, 2013
    This is a really nice feature, does there exist a possibility to output several findlines ? My usecase is to find some text with a regular expression which covers several lines of code, it would be nice to have all of them in the findresult

  • Anonymous
    March 26, 2014
    This feature seemed to disappear in VS 2012. Is there a known alternative?

  • Anonymous
    September 11, 2014
    Works fine in VS 2013 (which is 12.0 in the registry)

  • Anonymous
    December 09, 2014
    Is there any way to make this work with the Find Symbol Result window ? It seems to be almost exactly the same type of window but the format string is not applied.

  • Anonymous
    March 04, 2015
    I tried it in VS 2013 and it did not work. When VS loads it deletes the Find result format string.

  • Anonymous
    March 20, 2015
    The comment has been removed

  • Anonymous
    May 13, 2015
    The comment has been removed

  • Anonymous
    August 31, 2015
    This is amazing. Just confirmed that it works in Visual Studio 14.0 as well. Thanks a lot!