Configuring Browsers - adampresley/sublime-view-in-browser GitHub Wiki
By default the View In Browser plugin opens files in Firefox. You can of course configure this to open in any browser of your choice.
Changing Your Default Browser
The easiest change you can make is to change the browser this plugin uses to view your content. The default option is Firefox, but this can clearly be anything you set it up to be. The View In Browser plugin comes with options to support Firefox, Safari, Chrome, Chromium, and Internet Explorer. To choose a different browser you will need to override the existing setting.
Creating the Settings File
To override the plugin's default setting you will need to create a file in your user profile directory and populate it. Don't worry, this isn't as hard as it sounds. The quickest way to do this is to select Browse Packages... from the Preferences menu. This will open up the Sublime Text package installation directory.
Once there find a folder named User and open it. Inside this folder create a new file (if you haven't made one already) and call it View In Browser.sublime-settings. For illustration purposes let's say you want your default browser to be Google Chrome. To do this populate this new settings file with the following.
{
"selectedBrowser": "chrome"
}
After you save this file you can test your new settings file by pressing CTRL + ALT + V and you should see your new settings file open in Google Chrome, assuming you have it installed of course.
Supported Browsers
By default the following browsers and installation locations are supported. This list will show you the name of the browser, the location it is expecting to find it, and what name to use in the selectedBrowser key in the settings file (see above).
- firefox
- Windows - C:\Program Files (x86)\Mozilla Firefox\firefox.exe
- OS X - System path
- Linux - System path
- safari
- OS X - System path
- iexplore
- Windows - C:\Program Files\Internet Explorer\iexplore.exe
- chrome
- Windows - %Local AppData%\Google\Chrome\Application\chrome.exe
- OS X - /Application/Google Chrome.app
- Linux - System path
- chromium
- Linux - System path
Editing Supported Browsers
Provided along with the plugin is a default View In Browser.sublime-settings file which contains all the settings for the browsers listed above. That looks like this.
{
"supportedBrowsers": {
"firefox": [
{
"osname": "posix",
"platform": ".*",
"command": "firefox"
},
{
"osname": "nt",
"platform": "win32",
"command": "C:/Program Files (x86)/Mozilla Firefox/firefox.exe"
}
],
"safari": [
{
"osname": "posix",
"platform": "darwin",
"command": "open -a safari"
}
],
"iexplore": [
{
"osname": "nt",
"platform": "win32",
"command": "C:/Program Files/Internet Explorer/iexplore.exe"
}
],
"chrome": [
{
"osname": "posix",
"platform": "darwin",
"command": "open -a \"/Applications/Google Chrome.app\""
},
{
"osname": "posix",
"platform": "linux.*",
"command": "google-chrome"
},
{
"osname": "nt",
"platform": "win32",
"command": "%Local AppData%/Google/Chrome/Application/chrome.exe"
}
],
"chromium": [
{
"osname": "posix",
"platform": "linux.*",
"command": "chromium"
}
]
},
"selectedBrowser": "firefox"
}
You might find that you need to modify the path to a browser, or even add a browser. To do this you must edit the View In Browser.sublime-settings file found in your User package directory (which you hopefully created at some point). If you do not recall this file please see the above section named Creating the Settings File.
For illustration purposes let's pretend you are changing the path to Chrome in Windows. You can copy the above settings in your user View In Browser.sublime-settings file and alter the path for the Chrome browser for Windows.
Changing Browser for Right-Click -> View in Browser
You might find that you need to modify the path to a browser, or even add a browser. To do this you must edit the View In Browser.sublime-settings file found in your User package directory (which you hopefully created at some point). If you do not recall this file please see the above section named Creating the Settings File.
For illustration purposes let's pretend you are changing the path to Chrome in Mac OS X. You can copy the below settings in your user View In Browser.sublime-settings file and alter the path for the Chrome browser for Mac.
Enter the following code (This is for Mac OS X)
{
"posix": {
"linux": {
"firefox": "firefox -new-tab",
"chrome": "google-chrome",
"chrome64": "google-chrome",
"chromium": "chromium"
},
"linux2": {
"firefox": "firefox -new-tab",
"chrome": "google-chrome",
"chrome64": "google-chrome",
"chromium": "chromium"
},
"darwin": {
"firefox": "open -a \"/Applications/Firefox.app\"",
"safari": "open -a \"/Applications/Safari.app\"",
"chrome": "open -a \"/Applications/Google Chrome.app\"",
"chrome64": "open -a \"/Applications/Google Chrome.app\""
}
},
"nt": {
"win32": {
"firefox": "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe -new-tab",
"iexplore": "C:\\Program Files\\Internet Explorer\\iexplore.exe",
"chrome": "%Local AppData%\\Google\\Chrome\\Application\\chrome.exe",
"chrome64": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
}
},
"browser": "chrome"
}
Windows Considerations
One of the things you may notice in the Windows configuration for Google Chrome ("chrome") is a variable in the command path that looks like: %Local AppData%. This is a reference to your Windows installation's AppData folder in your user profile directory. There is a variable there because this value will differ for each user on your computer, and Chrome installs to your AppData folder.
Here is a list of supported variables:
- AppData - Your main application data folder for your profile (usually roaming)
- Personal - Your documents location
- Desktop - The path to your Desktop location (may be unreliable)
- Start Menu - The path to your Start Menu items location
- Local AppData - Your local application data folder for your profile
- My Video - Path to your videos location
- My Pictures - Path to your pictures location
- My Music - Path to your music location
Note that many of these are not terribly useful for determining browser location, unless you have decided to install Firefox in your My Music folder.