Open browser in Sublime text2

1. 新建一个插件

Go to Tools > New Plugin. Copy and paste this in the plugin:

open_browser.py
import sublime, sublime_plugin
import webbrowser

class OpenBrowserCommand(sublime_plugin.TextCommand):
   def run(self,edit):
      url = self.view.file_name()
      webbrowser.open_new(url)

2. 增加一个快捷键

Save this in your User folder of Sublime's packages.
Open up your User Keybindings. (Tools > Command Palette > User Key bindings)
Add this somewhere to the list:

Default.sublime-keymap
{ "keys": ["ctrl+shift+b"], "command": "open_browser" }

3. Done!搞定,现在按下快捷键就会自动在浏览器打开你编辑的页面

You can make the "keys" anything you want. Now when you're in a HTML file, just press that command.