这个其实用 Package 有点多了,感觉自己写一个类似下面的OpenUrlInBrowser.py
放到 User 目录下面也就差不多了。
import sublime, sublime_plugin, os, subprocess
class OpenUrlInBrowserCommand(sublime_plugin.TextCommand):
def run(self, edit):
for region in self.view.sel():
if not region.empty():
s = self.view.substr(region)
if s.find('.') == -1 and s.find('://') == -1 :
s = 'http://google.com/search?q='+s.replace(' ','+')
command = "C:\\Program Files\\Mozilla Firefox\\firefox.exe " + s
subprocess.Popen(command)
然后在 User 目录下新建:Context.sublime-menu,就可以在选中的上下文 url 中打开浏览器了。
[
{ "caption": "-", "id": "file" },
{ "command": "open_url_in_browser", "caption": "Open in Firefox" }
]