Sublime Forum

OpenUri - Opening URIs (mostly URLs) in your file




OpenUri is a customizable plugin that allows you to open URIs (mostly for URLs) in your file via a web browser directly by clicking on the phantom, popup or key/mouse bindings.

Here are featured customizable settings:

  • You are able to add new schemes and path-matching regexes by yourself.
    Schemes and path-matching regexes will be optimized into one single regex for finding URIs.

  • There are 3 ways to emphasize URIs’ location. You can use the one which fits you the best, or disable them all and only use a key/mouse binding to open URIs.

    • If show_open_button is configured to be always: Phantom will be added next to a URI (both image and color can be customized)
    • If show_open_button is configured to be hover: Popup will be used when a URI is hovered (text, image and color can be customized)
    • emphasize URL regions (can be solid background, underline, bordered)

Plugins for a similar purpose but less customizable:



This package is great. One question, though. Can you somehow make it open the URI in Sublime Text instead of opening it in the browser? That would be marvelous.



Didn’t aware that Python can open a URI without the help of a web browser. (searched via keyword python open uri on Google)

file:// should be able to be directly open in ST but not implemented though.



That’s beyond my comprehension of Python, but I wasn’t referring to that. If, instead of hitting that button OpenUri displays, I select the complete URI, and copy it into the Open File dialog, the contents of that “file” will be displayed in Sublime Text. Or at least that happens on Windows. Now, I’m aware that has very little to do with ST, Windows will download it to some sort of cache file and will open that instead of the URI itself, still it behaves as if it had opened that URI.
My question is, is it possible to somehow mimic that whole procedure instead of doing it manually?



That can be done theoretically but I doubt that should be the default behavior. Say I click on the text and it downloads the HTML source code of it and opens it in ST. I will feel “what the hell?” in my mind.



Well, that wording wasn’t very clever on my part, was it? :grinning: I didn’t mean to open the contents in ST instead of the browser by default. It’s pretty clear that most people want this to use the browser.

What I meant was if it was possible (generally) to do “a” instead of “b”?

I’ve unsuccessfully tried to mutilate your code (my apologies :fearful:) to do that, and I’m fairly convinced that self.view.window().open_file(uri) instead of webbrowser.get(browser).open(uri, autoraise=True) in open_uri_with_browser won’t do a decent job.



So, is this what you want? Or there is another scheme that I wan’t aware of to be opened in ST?
I can image that file:// is better to be opened with ST rather than a web browser.

Could you provide an exact sample rather than a concept? I.e., what’s the exact URI you are trying to open with ST?



Mostly (currently) it’s a bunch of xml files located under a https address. Otherwise, literally anything. For example, take that comment in referencing
I open that in ST using the Open File dialog (see in



With the video, you want to open a URL in ST so you can view the source code directly in ST, right?

Oh, it looks like view.window().open_file('') just not work.



Yes, that’s what I’ve tried to use instead of webbrowser.get(browser).open(uri, autoraise=True) in open_uri_with_browser