xof*_*ofz 134 hyperlink visual-studio
如果源文件注释中有URL,我可以"按住CTRL并单击以关注链接".但是,当我这样做时,链接在Visual Studio中打开.如何在我的网络浏览器中打开它 - 在我的情况下,谷歌浏览器?
小智 7
我找不到这个设置所以我写了一个你可以使用的简单宏.您可以将其绑定到像所有宏一样的键组合.这将完成工作,直到我们得到更好的答案.
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
Run Code Online (Sandbox Code Playgroud)
只需将光标放在网址前面并运行宏...
这是对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
Run Code Online (Sandbox Code Playgroud)
使用:将光标放在URL之前的某处; 运行宏(我映射到Ctrl-Shift-G)
| 归档时间: |
|
| 查看次数: |
20068 次 |
| 最近记录: |