Sublime Forum

Browser preview in localhost


I realize they’re ways to open files in a browser (builds, plugins, and packages).
What I want to do is have the file open locally.I maybe missing something because it used to work. RIght now the preview generates the following in the navigation file:///Applications/MAMP/htdocs/ instead of localhost/

I know since I am using LiveReload, I could just type in localhost/ once and it would refresh afterwards on it’s own. And for that matter I could do that in all my testing browsers. But that would mean at least 3 other times!

Come on there has to be folks like me who have watched Paul Irish and want to be efficient!

I have been searching for a few days and don’t feel like going back to coda2…Please help!



I’m a bit late but this should work.
You can do it by creating a new build system (in Tools > Build System > New Build System…) and doing replacement in the $file variable to change “/Applications/MAMP/htdocs/” to “http://localhost”.

Something like this should work for you:

	"cmd": "open", "-a", "Safari", "${file/\\/Applications\\/MAMP\\/htdocs/http:\\/\\/localhost/}"]

Escaping the slashes makes it look complicated but the base format is ${file/search/replace/} and each / has to be escaped with \.

Once you have selected this Build System, you should be able to preview any file under the htdocs directory on localhost with CMD+B.



How would I do the same but without using MAMP, I just Apache setup.