So I’ve been trying two different methods to have sublime open up in different browsers. First Is the one originally used back when I first got sublime and wanted chrome as my default browser. I downloaded the view in browser package. Went to prefrences > package settings > view in browser > settings-user > then pasted this in
This worked then, but I can delete this and chrome will still open up? I also can change the ‘c’ & ‘chrome’ to ‘f’ and ‘firefox’ but that doesn’t work? I then found an article that told me to go prefrences > key bindings > and paste this in
This doesn’t go in your user preferences, it’s a key binding. As it happens the content is valid for settings, it’s just setting settings that the package doesn’t do anything with (keys, command and args). As such, the package works the same whether it’s there or not.
Additionally, if you use View Package File from the command palette, enter the text view in browser keymap and select the one for your Windows, you’ll see this (all three files have the same content though):
Those are the bindings that you’re putting into your user bindings. The bindings in your User settings override all other key bindings, but since you’re overriding them with the same content as already exists that has no effect.
From your SO question we know that you’re using windows, and that when you press the key binding, you see this in the console:
git: untracking working dir C:\Users\Marian\Desktop\codeProjects\c4
View In Browser plugin v2.0.0, Python 3
C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
The first line is unrelated; that’s Sublime noticing that you have closed a file in a git folder and it doesn’t need to watch that repository for changes any longer.
The last two lines are the plugin announcing itself doing something. On my machine when I hit the key for Chrome, I see this in the console:
View In Browser plugin v2.0.0, Python 3
google-chrome file:////tmp/bob/sublime_text_3_3208/Data/Packages/User/View%20In%20Browser.sublime-settings
This is somewhat similar to yours, except notice that in my example the name of the chrome executable is followed by the name of the actual file. In your post, no filename is given.
So one potential reason why this might not be working for you is that you didn’t save the file that you tried to run it on. In particular, if you just create a new tab and type some text into it, it doesn’t appear on disk as a file until you save it.
The key bindings are all executing an external program and telling them to display a file; if there is no file to display, it won’t do anything interesting except start your browser or switch to it without doing anything, which from what you said above sounds like what it’s doing:
Now in my case, it is showing the command and the filename, but it’s still doing nothing. That’s because on my machine, the name of Chrome isn’t google-chrome, it’s google-chrome-stable. So whatever the plugin is trying to do, it’s failing because it’s not trying to execute the correct program (and for whatever reason it doesn’t feel the need to generate an error message when it happens, which is kind of sloppy).
This would lead me to believe that if your copy of Chrome is not installed in the location where the package thinks it will be installed, it’s trying to run something that doesn’t exist and failing silently.
Fixing that is a matter of choosing Preferences > Package Settings > View in Browser > Settings - Default and Preferences > Package Settings > View in Browser > Settings - User, then copying all of the content from the default and replacing all of the content in the user settings with it, followed by updating the paths to Chrome and your other browsers and saving the file. You can examine the shortcuts to your browsers to determine where they’re installed if you’re not sure.
I would try making sure that you’re running it on a file that exists on disk first, though. Also you can remove the key bindings that you added unless you want to change what they do.
Thank you for responding in such detail I appreciate it! I Must apologize though. I’m not technical at all and have been cutting corners in my self taught education of web development. Dealing with problems as they arise, sometimes more than once because I forgot the answer I was given months before lol. Anyway I really need my hand held through fixes like this. I can’t say I really understood the first half of your response due to my lack of technical knowledge. But getting straight to the fix I copied the default settings and pasted them in the user settings like you said. Next with the paths. I Don’t know how to reset them or use the command prompt if that’s required. Though I can find the shortcut. The start in: “C:\Program Files (x86)\Google\Chrome\Application”
The target: “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”
The first step would be some troubleshooting to see if the key binding does anything or nothing at all.
Make sure Chrome is not running and then hit the key binding. If nothing at all happens, then you need to focus on telling it where Chrome is. In this case, double check the console, where the command is telling you where it thinks Chrome is and then go to that location in the windows file browser; do you see the file named there?
If not, right click on your Chrome shortcut in windows and hit Properties to see where it’s being stored, then put that path into the configuration file (make sure you keep the paths in the same general format as how they are in there, with the \\ for every \); modify the part of the file that looks like what the console said it was running.
If Chrome starts up (even if it doesn’t open the file) then the problem isn’t the path.
In that case, double click some web file in the File explorer to open it in Chrome, then open the same file in Sublime and try the key binding to see what happens.
It’s hard to say what the problem is per se because this package doesn’t display any errors when it tries to open the browser and it fails, but as far as I can tell from playing with it briefly it always shows you not only the browser it’s running and the file that it’s trying to view, but in your pastes it’s not showing a file, which makes it appear as if you’re just typing in some HTML in a new tab and trying to view it, which won’t work.