How do I open links in Visual Studio in my web browser and not in Visual Studio?

Visual StudioHyperlink

Visual Studio Problem Overview


If there is a URL in a source file comment, I can "CTRL + click to follow link." However, when I do this, the link opens inside Visual Studio. How can I make it open in my web browser--in my case, Google Chrome?

Visual Studio Solutions


Solution 1 - Visual Studio

There is an extension that provides this behavior called Open in External Browser. It works in Visual Studio 2012, 2013, 2015 and 2017. (An old version available on GitHub supports Visual Studio 2010.)

Thanks goes to Dmitry for pointing this out in his answer to this similar question.

EDIT: The Visual Studio team is finally starting to work on putting this right into Visual Studio. Status of this feature request just moved from "Under Review" to "Started".

Solution 2 - Visual Studio

I could not find a setting for this so I wrote a simple macro that you can use. You can bind this to a key-combo like all macros. This will get the job done until we get a better answer.

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

Just put your cursor in front of the url and run the macro...

Solution 3 - Visual Studio

This is an improvement on the macro suggested above by mracoker.

This macro looks for a URL on the current line and does not capture text after the URL as the previous answer did.

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

To use: place cursor somewhere before the URL; Run Macro (I mapped to Ctrl-Shift-G)

Solution 4 - Visual Studio

2019 Update: All the answers are old. There's now a native way to do this in options in VS2019 Community:

Options >> Web Browser

Solution 5 - Visual Studio

This works for me. I changed the default browser in Windows.

Windows-Support

or direct link to settings: ms-settings:defaultapps

Solution 6 - Visual Studio

In VS2008 , just right click on the link and select "Open link in external window". You have to select Chrome as your default browser.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionxofzView Question on Stackoverflow
Solution 1 - Visual StudiomikesigsView Answer on Stackoverflow
Solution 2 - Visual StudiomracokerView Answer on Stackoverflow
Solution 3 - Visual StudioTerrenceView Answer on Stackoverflow
Solution 4 - Visual Studiodylanh724View Answer on Stackoverflow
Solution 5 - Visual StudiochristrisView Answer on Stackoverflow
Solution 6 - Visual Studiobackslash17View Answer on Stackoverflow