I have the same macro as @Fosco.
' Members for the search methods Private matchCase As Boolean = True Private searchWindowOne As Boolean = False Public Sub SearchFiles(ByVal fileTypes As String, ByVal searchPath As String) searchWindowOne = Not searchWindowOne DTE.Find.Target = vsFindTarget.vsFindTargetFiles DTE.Find.MatchCase = matchCase DTE.Find.MatchWholeWord = matchWholeWord matchCase = True matchWholeWord = True DTE.Find.MatchInHiddenText = True DTE.Find.Action = vsFindAction.vsFindActionFindAll DTE.Find.SearchPath = searchPath If (searchWindowOne) Then DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1 Else DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults2 End If DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral DTE.Find.SearchSubfolders = True DTE.Find.FilesOfType = fileTypes DTE.Find.FindWhat = GetClipboard() If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then Throw New System.Exception("vsFindResultNotFound") End If End Sub Public Sub ChangeMatchCase() matchCase = False matchWholeWord = False End Sub
This adds a bit more flexibility to the original approach. One of the good things is to search in both search boxes alternating . This means that your last two requests are always available. Of course, this cannot be used to directly map to a shortcut, but this allows you to do this:
Sub SearchInProject() SearchFiles("*.*", "Current Project") End Sub Sub SearchInCode() SearchFiles("*.h;*.cpp", "Entire Solution") End Sub
... and so on. Then they can be mapped to shortcuts and allowed a real search for a single key. As you may have noticed, I added a switch for the match case, which can be activated by the ChangeMatchCase macro for the next search. In my setup, I matched various searches with double keystrokes. So Ctrl+F,Ctrl+G searches around the world, Ctrl+F,Ctrl+D searches in the project, ... you get the point. I have similar mappings for all debugging materials, starting with Ctrl+D, Perhaps this has been the most important productivity increase in recent years.
source share