Sublime: Open URL to my file in Firefox browser with a shortcut key

How to use a shortcut key in Sublime for opening webbrowser with a URL. Topics: Shortcut keys, transforming file location to a URL, open webbrowser wich is not standard. …

So you're writing on your webpage in Sublime, and want to open it in your favorite dev webbrowser – which unfortunetaly isn't the default one? So "firefox = webbrowser.get('firefox')" doesn't work here and I have to find a different way.

So first of all: Preferences -> Key bindings (User)

Default (Windows).sublime-keymap:

    "keys" : ["ctrl+shift+b"],
    "command": "open_browser"


import sublime, sublime_plugin
import subprocess

class OpenBrowserCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    url = self.view.file_name()
    # print url
    url = url.replace('\', '/')
    # replace path
    url = url.replace('C:/inetpub/wwwroot', 'http://mymachine')
    # print url
    pid = subprocess.Popen(["C:\Program Files (x86)\Mozilla Firefox\firefox.exe", url]).pid

Nice… Thanks to the people where I get this hacks from.