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

时光怂恿深爱的人放手 提交于 2019-12-01 12:24:18

问题


I followed the instruction for windows 7 to setup chrome. No luck!

{
 "cmd":["C:\Program Files (x86)\Google\Chrome\Application", "$C:\Users\gmu\Desktop\June_15_2012"]
}

after entering the file location/path under what format should I have to save. I am a noobie. sorry to ask this question. Anything helps!

If I press f7 getting the following message Error trying to parse build system: Invalid escape in C:\Users\gmu\AppData\Roaming\Sublime Text2\Packages\User\Chrome.sublime-build:2:9

Thanks


回答1:


  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




回答2:


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.




回答3:


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



回答4:


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.



来源:https://stackoverflow.com/questions/11059114/sublime-text-2-keyboard-shortcut-to-open-file-in-chrome-firefox-in-windows

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