Sunday, March 24, 2019

Customize Find in Files Find Results format of results

So Im using VS 2017, find in files, the Find Results is displaying an awful long result for each file name found as the result of a search. This makes it difficult to quickly ascertain the fie name. Previous versions of VS by default displayed the file name, it seems (for me atleast) that VS 2017 is displaying the Full name in Find Results. See example here





To resolve we would like to view FileName or relative full name in the Find Results.
To do this, we need to implement a per version solution for VS:

>= VS 2017

  • Close Visual Studio 2017
  • Open regedit
  • Open bin file:
"C:\Users\[userName]\AppData\Local\Microsoft\VisualStudio\15.0_f294cc8e\privateregistry.bin"
  • Select HKEY_LOCAL_MACHINE from the left bar
  • Select File > Load Hive...
  • Load the privateregistry.bin file from %localappdata%\Microsoft\VisualStudio\15.0_[instanceid]{RootSuffix}\privateregistry.bin. The RootSuffix for a normal VS installation will be blank. This is mostly used for the experimental instance
  • Name the key whatever you want (e.g. "VS2017") when prompted
  • From there, you should be able to view the entries just like any normal registry.
  • Customize it according to accepted answer's suggestions.
  • Once you're finished, you need to make sure that you "Unload" the private registry, by selecting the "root" key ("VS2017" in this example) and selecting File > Unload Hive . If you don't do this, VS won't be able to read the privateregistry.bin file when it runs, causing major problems
< VS 2017
Using regedit:
See article Customize how Find in Files results are displayed in the Find Results Window:
Example here


Format specifiers:
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
  • \$ - $

No comments:

Post a Comment