Skip to content

Instantly share code, notes, and snippets.

@dogancelik
Last active October 5, 2015 13:57
Show Gist options
  • Save dogancelik/2815755 to your computer and use it in GitHub Desktop.
Save dogancelik/2815755 to your computer and use it in GitHub Desktop.
(Sublime Text) How to view/open file in browser in Sublime Text 2?

How to view/open file in browser in Sublime Text 2?

  1. Open Sublime Text 2.
  2. Go to Tools and click on New Plugin...
  3. Copy and paste the Python code below.
  4. Save it as Open In Browser.py in /Packages/User/ (If you can't find the folder, go to Preferences > Browse Packages...)
  5. Go to Preferences and click on Key Bindings - User
  6. Copy and paste the code below to your existing key bindings file and save the key bindings file.
  7. Now you will be able to open the current opened file in your default browser (with Windows+E keys)
[
// ... your key bindings here, if you don't have any, just ignore this line ...
{ "keys": ["super+e"], "command": "open_in_browser" }
]
import sublime, sublime_plugin
import webbrowser
class OpenInBrowser(sublime_plugin.TextCommand):
def run(self, edit):
webbrowser.open(self.view.file_name())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment