Skip to content

Instantly share code, notes, and snippets.

@robmccormack
Created August 22, 2013 20:04
Show Gist options
  • Save robmccormack/6312090 to your computer and use it in GitHub Desktop.
Save robmccormack/6312090 to your computer and use it in GitHub Desktop.
openhelp.py
import sublime, sublime_plugin
import webbrowser
# from: http://www.sublimetext.com/forum/viewtopic.php?f=2&t=2005
# https://www.google.com/search?q=car
# Sublime Text something
# sublime.status_message("User said" )
# variable is correct in class, would be wrong to put oust as gloa=bal
# http://stackoverflow.com/questions/6475321/global-variable-python-classes
class OpenHelpCommand(sublime_plugin.TextCommand):
googleLink = 'https://www.google.com/search?q={0}';
def run(self,edit):
for region in self.view.sel():
if not region.empty():
syntax = self.view.substr(region)
webbrowser.open_new(self.googleLink.format(syntax))
else:
self.view.window().show_input_panel("Search Google", '', self.on_done, None, None)
def on_done(self, user_input):
syntax = user_input
webbrowser.open_new(self.googleLink.format(syntax))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment