Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio : Is there a way to Perform a "Find in files" with one single shortcut?

I want to select an expression in code and type Ctrl+Whatever
so it has the same result as [ Ctrl+Shift+F AND Clicking on "Find All" ]

EDIT : [Ctrl+Shift+F AND Hitting Enter] may be quicker than clicking but I still want something more specific and faster

Remark : I am NOT interested the Find All References shortcut.

like image 414
Mehdi LAMRANI Avatar asked Feb 12 '11 21:02

Mehdi LAMRANI


2 Answers

You could use a macro. I recorded and modified one in VS2010:

Sub FindAllFiles()
    DTE.Find.FindWhat = DTE.ActiveDocument.Selection.ToString()
    DTE.Find.Target = vsFindTarget.vsFindTargetFiles
    DTE.Find.MatchCase = False
    DTE.Find.MatchWholeWord = False
    DTE.Find.MatchInHiddenText = True
    DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
    DTE.Find.SearchPath = "Entire Solution"
    DTE.Find.SearchSubfolders = True
    DTE.Find.FilesOfType = ""
    DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1
    DTE.Find.Action = vsFindAction.vsFindActionFindAll
    If (DTE.Find.Execute() = vsFindResult.vsFindResultNotFound) Then
        Throw New System.Exception("vsFindResultNotFound")
    End If
End Sub

The macro can be set to a keyboard shortcut. See: http://msdn.microsoft.com/en-us/library/a0003t62(v=vs.80).aspx

like image 128
Fosco Avatar answered Oct 19 '22 23:10

Fosco


Not that I would be aware of it. Ctrl+Shift+F + ENTER (ENTER instead of Clicking on "Find All") is probably the closest it comes. And if you are a touch typist it is as fast as a single shortcut.

Update

Now, that the question has changed my answer makes no sense anymore. Go with a macro like Fosco answered it.

like image 38
Martin Buberl Avatar answered Oct 20 '22 00:10

Martin Buberl