For example, how to configure the f12 shortcut in sublimetext3 to open and browse the PHP file in the browser, and it is in the localhost path. In segmentfault, the answer is to modify openinbrowser. path content in The py file,... for example, in sublime text 3, how can I configure the f12 shortcut like in dreamweaver to open the PHP file in the browser, and it is in the localhost path.
In segmentfault, the answer is to modify the path content in the open in browser. py file, but I don't know how to change the path. The content is as follows:
import sublime, sublime_pluginimport webbrowser class OpenInBrowserCommand(sublime_plugin.TextCommand): def run(self, edit): if self.view.file_name(): webbrowser.open_new_tab("file://" + self.view.file_name()) def is_visible(self): return self.view.file_name() != None and (self.view.file_name()[-5:] == ".html" or self.view.file_name()[-5:] == ".HTML" or self.view.file_name()[-4:] == ".htm" or self.view.file_name()[-4:] == ".HTM")
Then, you can find a way to add an open browser. py file with the following content:
import sublime, sublime_plugin import webbrowser url_map = { 'D:\Program Files\wamp\www' : 'http://localhost', } class OpenBrowserCommand(sublime_plugin.TextCommand): def run(self,edit): window = sublime.active_window() window.run_command('save') url = self.view.file_name() flag = False for path, domain in url_map.items(): if url.startswith(path): url = url.replace(path, domain).replace('\\', '/') flag = True break if not flag: url = 'file://' + url webbrowser.open_new(url)
However, there is no sense of pressing the shortcut key after adding it. My path is correctly configured.
My understanding is whether the content of the last file can be integrated into the first file. You can use the shortcut key of open in browser to control browsing in the browser and use localhost/path.
Hope you can save it !!!
Reply content:
For example, in sublime text 3, how can I configure the f12 shortcut like in dreamweaver to open the PHP file in the browser, and it is in the localhost path.
In segmentfault, the answer is to modify the path content in the open in browser. py file, but I don't know how to change the path. The content is as follows:
import sublime, sublime_pluginimport webbrowser class OpenInBrowserCommand(sublime_plugin.TextCommand): def run(self, edit): if self.view.file_name(): webbrowser.open_new_tab("file://" + self.view.file_name()) def is_visible(self): return self.view.file_name() != None and (self.view.file_name()[-5:] == ".html" or self.view.file_name()[-5:] == ".HTML" or self.view.file_name()[-4:] == ".htm" or self.view.file_name()[-4:] == ".HTM")
Then, you can find a way to add an open browser. py file with the following content:
import sublime, sublime_plugin import webbrowser url_map = { 'D:\Program Files\wamp\www' : 'http://localhost', } class OpenBrowserCommand(sublime_plugin.TextCommand): def run(self,edit): window = sublime.active_window() window.run_command('save') url = self.view.file_name() flag = False for path, domain in url_map.items(): if url.startswith(path): url = url.replace(path, domain).replace('\\', '/') flag = True break if not flag: url = 'file://' + url webbrowser.open_new(url)
However, there is no sense of pressing the shortcut key after adding it. My path is correctly configured.
My understanding is whether the content of the last file can be integrated into the first file. You can use the shortcut key of open in browser to control browsing in the browser and use localhost/path.
Hope you can save it !!!
To be honest, I will not configure this, but the green version I downloaded has been integrated. You can preview it in the default browser by pressing Ctrl + Shift + press Enter, you can also right-click "open in Browser" in sublime ". You can refer to the following example.