从 Visual Studio 在浏览器中加载搜索 URL [英] Load search URL in browser from Visual Studio
问题描述
我发现内置的 Visual Studio 文档资源管理器相关性,尤其是当我使用的更多 SDK 具有最新的在线内容强>.按 F1 启动文档资源管理器通常会显示一些无用的内容,并且对我来说不再可用.
I'm finding the built-in Visual Studio Document Explorer less relevant, especially as more of the SDKs I work with have the most up-to-date content on-line. Pressing F1 starts Document Explorer usually with something unhelpful and it's not usable any more for me.
有什么方法可以在Visual Studio 中按下组合键:
- 默认浏览器会打开搜索引擎的网址
- 使用的查询是当前光标位置下的关键字
- 添加了一个过滤器,例如
site:msdn.microsoft.com
我对 VS 中的宏一无所知,但大概这就是我所需要的.有谁知道如何进行设置?codez 会很好!
I don't know anything about macros in VS but presumably that's what I need. Does anyone know how to go about setting this up? teh codez would be nice!
推荐答案
这是另一个版本(基于 Alex 的回答),它也将选择您所在的当前单词.更像是典型的 F1 帮助.
Here is another version (based on Alex's answer) that will also select the current word you are on. More like the typical F1 help.
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module Search
Sub GoogleSearch()
AnySearch("http://www.google.com/search?q=.net+")
End Sub
Sub BingSearch()
AnySearch("http://www.bing.com/search?q=")
End Sub
Private Sub AnySearch(ByVal searchUrl)
Dim strUrl As String
Dim selection As String = GetSelection()
If selection <> "" Then
strUrl = searchUrl + selection
DTE.ExecuteCommand("nav", strUrl & " /ext")
Else
MsgBox("Select text to search for.")
End If
End Sub
Private Function GetSelection() As String
Dim selection As TextSelection = DTE.ActiveDocument.Selection()
If selection.Text <> "" Then
Return selection.Text
Else
DTE.ExecuteCommand("Edit.SelectCurrentWord")
selection = DTE.ActiveDocument.Selection()
Return selection.Text
End If
End Function
End Module
这篇关于从 Visual Studio 在浏览器中加载搜索 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!