如何在Web浏览器中而不是在Visual Studio中打开Visual Studio中的链接?

StackOverflow https://stackoverflow.com/questions/1201570

  •  05-07-2019
  •  | 
  •  

如果源文件评论中有URL,我可以“按CTRL +点击以关注链接。”但是,当我这样做时,链接在Visual Studio中打开。如何在我的网络浏览器中打开它 - 在我的情况下,谷歌浏览器?

有帮助吗?

解决方案

有一个扩展程序提供此行为,称为在外部浏览器中打开。它适用于Visual Studio 2012,2013,2015和2017.(旧版本可在GitHub上获得支持Visual Studio 2010。)

感谢 Dmitry 指出他对这个类似问题的回答。

编辑:Visual Studio团队终于开始将这个权利放到Visual Studio中了。状态功能请求刚刚从”审核中“移动到“开始”。

其他提示

我找不到这个设置所以我写了一个你可以使用的简单宏。您可以将其绑定到像所有宏一样的键组合。这将完成工作,直到我们得到更好的答案。

Sub OpenURLInChrome()
   'copy to end of line
   DTE.ActiveDocument.Selection.EndOfLine(True)

  'set var
   Dim url As String = DTE.ActiveDocument.Selection.Text

   'launch chrome with url
   System.Diagnostics.Process.Start( _
      Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) _
      + "\Google\Chrome\Application\chrome.exe", url)
End Sub

只需将光标放在网址前面并运行宏...

这是对mracoker上面建议的宏的改进。

此宏在当前行上查找URL,并且不会像上一个答案那样在URL之后捕获文本。

Sub OpenURLInChrome()

   ' Select to end of line
   DTE.ActiveDocument.Selection.EndOfLine(True)
   Dim selection As TextSelection = DTE.ActiveDocument.Selection

   ' Find URL within selection
   Dim match = System.Text.RegularExpressions.Regex.Match( _
      selection.Text, ".*(http\S+)")

   Dim url As String = ""
   If (match.Success) Then
      If match.Groups.Count = 2 Then
         url = match.Groups(1).Value
      End If
   End If

   ' Remove selection
   selection.SwapAnchor()
   selection.Collapse()

   If (url = String.Empty) Then
       MsgBox("No URL found")
   End If

   ' Launch chrome with url
   System.Diagnostics.Process.Start( _
      Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) _
      + "\Google\Chrome\Application\chrome.exe", url)
End Sub

使用:将光标放在URL之前的某处;运行宏(我映射到Ctrl-Shift-G)

2019更新:所有答案都是旧的。现在,在VS2019社区的选项中有一种本地方式可以做到这一点:

>网络浏览器”>

在VS2008中,只需右键单击链接并选择“在外部窗口中打开链接”即可。您必须选择Chrome作为默认浏览器。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top