<p>In Visual Studio 2005-2015 it is possible to find all lines containing certain references and display them in a "Find Results" window.</p>

<p>Now that these result lines are displayed, is there any keyboard shortcut that would allow adding debug breakpoints to all of them?</p>

[{'answer_id': 73120, 'author': 'Tom Ritter', 'author_id': 8435, 'author_profile': 'https://Stackoverflow.com/users/8435', 'pm_score': 2, 'selected': False, 'text': "<p>If you can search for the word exactly, you can use a pair of keyboard shortcuts to do it quickly.</p>\n\n<p>Tools -> Options -> Enviroment -> Keyboard</p>\n\n<ul>\n<li>Edit.GoToFindResults1NextLocation</li>\n<li>EditorContextMenus.CodeWindow.Breakpoint.InsertBreakpoint</li>\n</ul>\n\n<p>Assign them to Control+Alt+F11 and F10 and you can go through all the results very quickly.  I haven't found a shortcut for going to the next reference however.</p>\n"}, {'answer_id': 249501, 'author': 'Jeff Hillman', 'author_id': 3950, 'author_profile': 'https://Stackoverflow.com/users/3950', 'pm_score': 5, 'selected': True, 'text': '<p><strong><em>This answer does not work for Visual Studio 2015 or later. A more recent answer can be found <a href="https://stackoverflow.com/questions/38061627/how-do-i-add-debug-breakpoints-to-lines-displayed-in-a-find-results-window-in?rq=1">here</a>.</em></strong></p>\n\n<p>You can do this fairly easily with a Visual Studio macro.  Within Visual Studio, hit Alt-F11 to open the Macro IDE and add a new module by right-clicking on MyMacros and selecting Add|Add Module...</p>\n\n<p>Paste the following in the source editor:</p>\n\n<pre><code>Imports System\nImports System.IO\nImports System.Text.RegularExpressions\nImports EnvDTE\nImports EnvDTE80\nImports EnvDTE90\nImports System.Diagnostics\n\nPublic Module CustomMacros\n    Sub BreakpointFindResults()\n        Dim findResultsWindow As Window = DTE.Windows.Item(Constants.vsWindowKindFindResults1)\n\n        Dim selection As TextSelection\n        selection = findResultsWindow.Selection\n        selection.SelectAll()\n\n        Dim findResultsReader As New StringReader(selection.Text)\n        Dim findResult As String = findResultsReader.ReadLine()\n\n        Dim findResultRegex As New Regex("(?&lt;Path&gt;.*?)\\((?&lt;LineNumber&gt;\\d+)\\):")\n\n        While Not findResult Is Nothing\n            Dim findResultMatch As Match = findResultRegex.Match(findResult)\n\n            If findResultMatch.Success Then\n                Dim path As String = findResultMatch.Groups.Item("Path").Value\n                Dim lineNumber As Integer = Integer.Parse(findResultMatch.Groups.Item("LineNumber").Value)\n\n                Try\n                    DTE.Debugger.Breakpoints.Add("", path, lineNumber)\n                Catch ex As Exception\n                    \' breakpoints can\'t be added everywhere\n                End Try\n            End If\n\n            findResult = findResultsReader.ReadLine()\n        End While\n    End Sub\nEnd Module\n</code></pre>\n\n<p>This example uses the results in the "Find Results 1" window; you might want to create an individual shortcut for each result window.</p>\n\n<p>You can create a keyboard shortcut by going to Tools|Options... and selecting <strong>Keyboard</strong> under the <strong>Environment</strong> section in the navigation on the left.  Select your macro and assign any shortcut you like.  </p>\n\n<p>You can also add your macro to a menu or toolbar by going to Tools|Customize... and selecting the <strong>Macros</strong> section in the navigation on the left.  Once you locate your macro in the list, you can drag it to any menu or toolbar, where it its text or icon can be customized to whatever you want.</p>\n'}, {'answer_id': 797454, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>I needed something similar to disable all breakpoints and place a breakpoint on every "Catch ex as Exception". However, I expanded this a little so it will place a breakpoint at every occurance of the string you have selected. All you need to do with this is highlight the string you want to have a breakpoint on and run the macro. </p>\n\n<pre><code> Sub BreakPointAtString()\n\n    Try\n        DTE.ExecuteCommand("Debug.DisableAllBreakpoints")\n    Catch ex As Exception\n\n    End Try\n\n    Dim tsSelection As String = DTE.ActiveDocument.Selection.text\n    DTE.ActiveDocument.Selection.selectall()\n    Dim AllText As String = DTE.ActiveDocument.Selection.Text\n\n    Dim findResultsReader As New StringReader(AllText)\n    Dim findResult As String = findResultsReader.ReadLine()\n    Dim lineNum As Integer = 1\n\n    Do Until findResultsReader.Peek = -1\n        lineNum += 1\n        findResult = findResultsReader.ReadLine()\n        If Trim(findResult) = Trim(tsSelection) Then\n            DTE.ActiveDocument.Selection.GotoLine(lineNum)\n            DTE.ExecuteCommand("Debug.ToggleBreakpoint")\n        End If\n    Loop\n\nEnd Sub\n</code></pre>\n\n<p>Hope it works for you :)</p>\n'}, {'answer_id': 1631799, 'author': 'Dmytro', 'author_id': 194487, 'author_profile': 'https://Stackoverflow.com/users/194487', 'pm_score': 1, 'selected': False, 'text': '<p>Paul, thanks a lot, but I have the following error (message box), may be I need to restart my PC:</p>\n\n<pre><code>Error\n---------------------------\nError HRESULT E_FAIL has been returned from a call to a COM component.\n---------------------------\nOK   \n---------------------------\n</code></pre>\n\n<p>I would propose the following solution that\'s very simple but it works for me</p>\n\n<pre><code>Sub BreakPointsFromSearch()\n    Dim n As Integer = InputBox("Enter the number of search results")\n\n    For i = 1 To n\n        DTE.ExecuteCommand("Edit.GoToNextLocation")\n        DTE.ExecuteCommand("Debug.ToggleBreakpoint")            \n    Next\nEnd Sub\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/73063', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/12113/']