Sublime Forum

View in Browser

#1

How do I view in Browser? Is there some way to do this?

0 Likes

#2

Check out :

github.com/dz0ny/LiveReload-sublimetext2 or
github.com/Nijikokun/Prevu

Both are available via Package Control wbond.net/sublime_packages/package_control

0 Likes

#3

assuming you are talking about something like viewing a HTML file in the browser that you are editing; In the past I have just whipped up a custom build type and had it launch the current file in a browser with cmd-B.

But now, like one of the replies mentioned, I normally use LiveReload (not the ST2 plugin, though).

0 Likes

#4

If you want to use the build system as suggested above, this is how you do it:

Create a file [Packages]/User/Open in browser.sublime-build and put this into it:

{ "cmd": "start", "$file"], "selector": "text.htm|text.html", "shell": true }

You’ll find plugins for this but I found creating this simple build system convenient.

0 Likes

#5

Is it possible for more of a step-by-step approach please? We’re evaluating different text editors (textpad, editpad etc) but require a view in browser command.
Thanks - Sean

0 Likes

#6

[quote=“pdgmedia”]Is it possible for more of a step-by-step approach please? We’re evaluating different text editors (textpad, editpad etc) but require a view in browser command.
Thanks - Sean[/quote]

In my answer above you have a step-by-step instructions on how to add a new “build system” (confusing name in this case but don’t worry about it) that will open a browser whenever you press Ctrl + B or when you invoke the “build” from the main menu.

0 Likes

#7

Sorry - but I have no idea what this line means:
Create a file [Packages]/User/Open in browser.sublime-build and put this into it

0 Likes

#8

C’mon, is THAT hard to press alt+tab then ctrl+r for refresh? :open_mouth:

0 Likes

#9

Try livereload iamntz. I used to think the exact same way.

0 Likes

#10

[quote=“pdgmedia”]Sorry - but I have no idea what this line means:
Create a file [Packages]/User/Open in browser.sublime-build and put this into it[/quote]

[Packages] is just a plain folder on your filesystem, something like C:\Users\yourname\AppData\Roaming\Sublime Text 2\Packages if you are on Windows. You can open it from Sublime Text by clicking Preferences > Browse Packages.

Inside this folder, go to the User subfolder and create a file called “Open in browser.sublime-build” there - it should be a plain text file, just with a different extension. Than put that contents into there.

Hope this helps.

0 Likes

#11

Thanks! Ctrl B did indeed launch IE - but it was unable to display the html file for some reason.

0 Likes

#12

@atomi: I tried. On Windows is tricky to set up and to start (or at least it was a year ago or so). And no, I won’t change my os for some extension! :ugeek:

0 Likes

#13

It doesn’t work. It says “No Build System”

Does anyone know why this might not be working? Is borekb’s answer incomplete or is the information outdated?


  • Windows 7 x86
  • ST 3.0, Build 3143
0 Likes

#14

the migration from the old forum software lost the [ characters, just put one after "cmd":

1 Like

#15

kingkeith, thank you very much. That helped a bit.

But the answer is still incomplete isn’t it? I mean, now it just pops up terminal with the path where my html file is. So, in order to open it in the browser I need to type something like start browsername filename.html

BTW the $file is a variable for the path to my active tab file, right? Just to make it clear for myself.

0 Likes

#16

correct

if you’ve associated HTML files with a terminal application then yes, maybe just change the file association in Windows so it will open with your browser instead

btw, have you tried just right clicking anywhere in the view in ST and selecting “View in Browser”?

1 Like

#17

No, my HTML files are associated with Firefox browser. That is, if I double-click on any of them in the explorer it will open them in FF.

Unfortunately clicking on View in Browser from the context menu doesn’t do anything.

PS Also, I think I should add, just in case, that I’m using a portable version of the program.

0 Likes

#18

hmm, weird. Using portable ST shouldn’t make any difference here. I wonder why start filename.html doesn’t launch Firefox then…

Any errors in the ST console (View menu -> Show Console) when using the View in Browser context menu item?

0 Likes

#19

Well, I don’t see any. Running the build only adds one line to the console. In my case it’s this: Running start C:\Users\username\Desktop\roux_website\index.htm

Updated:

And clicking on View in Browser brought up this:

View In Browser plugin v2.0.0, Python 3
C:\Program Files (x86)\Mozilla Firefox\firefox.exe -new-tab file:///C:/Users/Ahu%20Lee/Desktop/roux_website/index.htm
Traceback (most recent call last):
  File "./python3.3/subprocess.py", line 1104, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Ahu\Portable Apps\Sublime Text Build 3143\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "ViewInBrowserCommand in D:\Ahu\Portable Apps\Sublime Text Build 3143\Data\Installed Packages\View In Browser.sublime-package", line 238, in run
  File "ViewInBrowserCommand in D:\Ahu\Portable Apps\Sublime Text Build 3143\Data\Installed Packages\View In Browser.sublime-package", line 191, in openBrowser
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1110, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
View In Browser plugin v2.0.0, Python 3
C:\Program Files (x86)\Mozilla Firefox\firefox.exe -new-tab file:///C:/Users/Ahu%20Lee/Desktop/roux_website/index.htm
Traceback (most recent call last):
  File "./python3.3/subprocess.py", line 1104, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Ahu\Portable Apps\Sublime Text Build 3143\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "ViewInBrowserCommand in D:\Ahu\Portable Apps\Sublime Text Build 3143\Data\Installed Packages\View In Browser.sublime-package", line 238, in run
  File "ViewInBrowserCommand in D:\Ahu\Portable Apps\Sublime Text Build 3143\Data\Installed Packages\View In Browser.sublime-package", line 191, in openBrowser
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1110, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
View In Browser plugin v2.0.0, Python 3
C:\Program Files (x86)\Mozilla Firefox\firefox.exe -new-tab file:///C:/Users/Ahu%20Lee/Desktop/roux_website/index.htm
Traceback (most recent call last):
  File "./python3.3/subprocess.py", line 1104, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Ahu\Portable Apps\Sublime Text Build 3143\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "ViewInBrowserCommand in D:\Ahu\Portable Apps\Sublime Text Build 3143\Data\Installed Packages\View In Browser.sublime-package", line 238, in run
  File "ViewInBrowserCommand in D:\Ahu\Portable Apps\Sublime Text Build 3143\Data\Installed Packages\View In Browser.sublime-package", line 191, in openBrowser
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1110, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
0 Likes

#20

I probably meant Open in Browser from the context menu, but nevermind. You’re on a 32 bit Windows 7 installation, you say? So not running into https://github.com/adampresley/sublime-view-in-browser/issues/75
Is Firefox installed to C:\Program Files (x86)\Mozilla Firefox\firefox.exe or somewhere else? You may need to change your View in Browser package settings if it is unable to detect it correctly automatically.

0 Likes