Sublime Forum

Open_in_browser Command name builds on operative system

#1

So the thing is I don’t “browse” html-files, I browse html-paths.

I used to press F3 to open html-files in my browser. This is my “Default (Windows).sublime-keymap”:
[
{ “keys”: [“f3”], “command”: “open_in_browser” },

]

When I realized that 97% of the times I open html-files I would like ST4 to open them.
So in my OS, I changed html to open with ST4,
unfortunately this breakes your open_in_browser-command that does not take any parameters afaik.

simple problem at your end: to either make parameters, or make two new commands, I suggest open_with_browser and open_in_ChromeORwhatever.

complex problem that involves MS too.

1 Like

#2

The open_in_browser commands calls into the Python standard library’s webbrowser module to do the heavy lifting. That underlying module does support asking for a specific browser so it’s certainly possible to do, whether by SublimeHQ or you writing a plugin command yourself.

1 Like

#3

Well, webbrowser already tries to register all known and available browsers upon first webbrowser.open() call. The py38 version however doesn’t know anything about Microsoft Edge. It only looks for Microsoft Internet Explorer with absolute path. Other browsers’ executables would need to be accessible via $PATH environment variable to be found.

Hence the only operation being registered is "windows-default" which opens a file with associated default program via os.startfile(url) .

webbrowser module supports configuring a user defined browser via BROWSER environment variable with fully qualified path to your favourite browser’s executable.

1 Like