Sublime Text 2 Keyboard shortcut to open file in Chrome/firefox in windows

杀马特。学长 韩版系。学妹 提交于 2019-12-01 13:54:58
joel
  1. preferences > key bindings-user should look like this in windows:

    [
    // *RIGHT* { "keys": ["f12"], "command": "open_browser" },
    // *WRONG* { "keys": ["f12"], "ctrl": "open_browser" }, 
    
    { "keys": ["f12"], "command": "open_browser" },
    { "keys": ["ctrl+e"], "command": "HtmlDialect" },
    { "keys": ["/"], "command": "close_tag_on_slash" }
    ]
    
  2. look in your packages folder for a folder called 'openbrow' then open the openbrow.py file in sublime

find the icon for the browser you want to use and goto it's properties to copy the path to it's location on your computer

then in the openbrow file your gonna paste that path where it should go. for instance ([r'C:\path to your browser', '-new-tab', self.view.file_name()])

here's what my openbrow.py file looks like:

    import sublime, sublime_plugin
    import subprocess

    class OpenBrowserCommand(sublime_plugin.TextCommand):
    def run(self,edit):
    subprocess.call([r'C:\Program Files 
    (x86)\Mozilla Firefox\firefox.exe','-new-tab', self.view.file_name()])

hope this helps! KCCO

Install the Sublime View In Browser extension that, quote:

View In Browser is a Sublime Text 2 plugin that will open whatever is in your current view/tab.

Installation in using instructions in tne README.md file.

User1911

I was having the same problem and found this post ! My problem was fixed by just typing this:

{
    "cmd": ["C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "$file"]
}

Notice that double \\ solved my problem ..

And then I saved it as Chrome.sublime-build on:

C:\Users\YourUsername\AppData\Roaming\Sublime Text 2\Packages\User

In my Windows this code is working. Go to Tools > Build System > New Build System Then put the code with your browser file path.

{
    "cmd": ["C:\\Program Files\\Mozilla Firefox\\firefox.exe", "$file"]
}

Please use double '\\' for '\'. Hope it will work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!