Sublime Text 2 keyboard shortcut to open file in s

2019-01-09 23:09发布

I do web development and am trying out Sublime Text 2. Is there a keyboard shortcut to open the current file in specified browser (e.g. Chrome)?

Any help to get setup in Sublime Text for web development is appreciated!

14条回答
Bombasti
2楼-- · 2019-01-09 23:33

Tools -> Build System -> New Build System. The type following as your OS, save as Chrome.sublime-build

Windows OS

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

MAC Os

{
   "cmd": ["open", "-a", "/Applications/Google Chrome.app", "$file"]
}

Save the file - Chrome.sublime-build in location

C:\Users\xnivirro\Downloads\Software-Installed\Sublime-2\Data\Packages\User
查看更多
ら.Afraid
3楼-- · 2019-01-09 23:33

or try this

"cmd": ["cmd","/K","start http://localhost/Angularjs/$file_name"]

查看更多
我只想做你的唯一
4楼-- · 2019-01-09 23:35

"Open in Browser context menu for HTML files" has been added in the latest build (2207). Its release date was 25 June 2012.

查看更多
时光不老,我们不散
5楼-- · 2019-01-09 23:36

This worked on Sublime 3:


To browse html files with default app by Alt+L hotkey:

Add this line to Preferences -> Key Bindings - User opening file:

{ "keys": ["alt+l"], "command": "open_in_browser"}


To browse or open with external app like chrome:

Add this line to Tools -> Build System -> New Build System... opening file, and save with name "OpenWithChrome.sublime-build"

"shell_cmd": "C:\\PROGRA~1\\Google\\Chrome\\APPLIC~1\\chrome.exe $file"

Then you can browse/open the file by selecting Tools -> Build System -> OpenWithChrome and pressing F7 or Ctrl+B key.

查看更多
Juvenile、少年°
6楼-- · 2019-01-09 23:36

On mac and sublime text 3 , which version is 3103, the content should be

{
    "shell_cmd": "open -a 'Google Chrome' '$file'"
}
查看更多
太酷不给撩
7楼-- · 2019-01-09 23:39

Install the View In Browser plugin using Package Control or download package from github and unzip this package in your packages folder(that from browse packages)

after this, go to Preferences, Key Bindings - User, paste this

[{ "keys": [ "f12" ], "command": "view_in_browser" }]

now F12 will be your shortcut key.

查看更多
登录 后发表回答