Visual Studio Tip: Customizing Search Output in Visual Studio

Sign in to queue

The Discussion

  • User profile image
    Rob

    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

  • User profile image
    JohnLudlow

    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.

  • User profile image
    dudumanbogd​anvlad

    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!

  • User profile image
    JonTims

    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]

     

  • User profile image
    JohnLudlow

    @JonTims: Sweet 

    Yeah the PowerShell script is better for copy-past-iness.

    And yes, @dudumanbogda​nvlad raises a good point that this would be useful in the Find Symbol / Find References windows

  • User profile image
    JohnLudlow

    BTW, I found this blog post which explains what the different specifiers mean:

    https://blogs.msdn.com/b/zainnab/archive/2010/01/03/customize-how-search-results-are-displayed-in-the-find-results-window.aspx

    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

  • User profile image
    HockeyGeek​Girl

    You guys are off and running with this! Thanks for sharing the powershell script!

  • User profile image
    Ela

    Very helpful. Thank you for posting.

Add Your 2 Cents