在本地机器 sublime 上打开 URL [英] Open up URL on local machine sublime
问题描述
当通过 view_in_browser 命令打开一个 URL 时,它会打开
<块引用>file:///Applications/MAMP/htdocs/file.php
相反,我希望它打开
<块引用>并粘贴以下内容:
<代码>{/应用程序/MAMP/htdocs/":{"url_testing":"http://localhost:8888/"}}
/Applications/MAMP/htdocs/:文件路径
现在,当您在计算机上按 control + l 时,它将打开带有 localhost 前缀的 URL.
希望这会有所帮助!
个人观察:sidebarenhacements 的细粒度控制非常好,但是如果您只是想绑定一个键来打开带有 localhost 的 chrome 窗口,而不管项目、url 类型、文件路径等,这会过于复杂.希望如此将来会改变.
When opening a URL via view_in_browser command it opens
file:///Applications/MAMP/htdocs/file.php
instead I want it to open
I was able to do it before, but it was set up 5 years ago and the computer is dead.
I don't want to do anything with project URLs or setup sidebar enhancement packages, I also tried creating a custom plugin as in https://forum.sublimetext.com/t/how-to-view-in-browser/3225/7
Which overrides the open_browser command, but it doesn't work.
Is there not an arg I can specify in the key bindings to prepend a URL? Something like
{ "keys": [ "super+e" ],
"command": "view_in_browser"
"args": {"url": "http://localhost:8888/"}
}
May be there's an existing package that does this?
Seems so simple, but is so complicated to do.. I'm on sublime 3
Couldn't find any other method apart from sidebar enhancements route so did the following
Installed sidebar enhancements, details here: https://www.hongkiat.com/blog/preview-in-localhost/
Opened the folder "htdocs" then right click folder > Project > Edit preview URLs
And pasted the following:
{
"/Applications/MAMP/htdocs/":{
"url_testing":"http://localhost:8888/"
}
}
/Applications/MAMP/htdocs/ : path to your files
http://localhost:8888/ : is path to local machine URL
Then go to Preference > Keybindings and in the right window paste
{ "keys": ["ctrl+l" ],
"command": "side_bar_open_in_browser" ,
"args":{"paths":[], "type":"testing", "browser":"Chrome"}
}
Now when you press control + l on the computer it will open up the URL with localhost prepended.
Hope this helps!
Personal observation: the granular control of sidebarenhacements is great and all, but this is overly complicated if you simply want to bind a key to open up chrome window with localhost prepended regardless of project, url type, file paths etc. Hope this is changed in the future.
这篇关于在本地机器 sublime 上打开 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!