Because of all the sub-directories my code typically lives in, whenever I do a Find In File for something, the code gets run off the screen because the results window has wasted so much valuable real estate by repeating the long file path for every object in my solution. More often than not, they are in the same parent directory, or I don't really care where there from.

Is there an option to shorten the path name to perhaps just the file?

Unnecessarily long

Also, the Display File Names Only option in the Find in Files dialog does not do this, it only omits the code from the result.

Find in Files Dialog

You can change the VS search result formatting by changing the registry.

According to the article Customize how Find in Files results are displayed in the Find Results Window:

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

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

Further, here's the syntax to use if you'd like to customize the string further:

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

  • \$ - $