Sublime-text3-about configuring a one-click browser in sublimetext3 to open the PHP file and is in the localhost local server path

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.