从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屋!