Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Making F1 do something useful in Visual Studio

0.00/5 (No votes)
12 Feb 2011 1  
F1 in Visual Studio takes forever, and rarely comes up with anything useful. Replace it with a Google MSDN search!
For Visual Studio 2008 and Visual Studio 2010:

1) Open VS, and on the Menu bar select "Tools...Macros...New Macro Project"
2) Call the project "GoogleSearchMSDN"
3) I'm so sorry about this, but VB is involved here. Not my fault, honest!
4) Rename the default Module1 to "DoGoogleSearchMSDN" - right click on the module name in the left hand pan, select "Rename"
5) Enter the following code as the module body:
Sub GoogleSearchMSDN()
    Dim url As String
    Dim searchFor As TextSelection = DTE.ActiveDocument.Selection()
    If searchFor.Text <> "" Then
        url = "www.google.com/search?q=MSDN+" + searchFor.Text
    Else
        url = "www.google.com/search?q=MSDN"
    End If
    DTE.ExecuteCommand("View.URL", url)
End Sub

6) Build and save your module.
7) Use the menu bar again: "Tools...Options...Environment...Keyboard"
8) In the "Show commands containing:" textbox, type "Google" - you should see your new macro.
9) Go to the "Press shortcut keys" box, and press F1
10) Press OK.

F1 now searches for "MSDN" plus whatever you highlighted.

[edit]Took out the "C#" reference in the "searches for" comment at the end - mine does, because I put that in the URL... :-O -- OriginalGriff [/edit]

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here