For Windows - Open your Default Browser - Tested on VS Code v 1.1.0
Answer to both opening a specific file (name is hard-coded) OR opening ANY other file.
Steps:
Use ctrl + shift + p (or F1) to open the Command Palette.
Type in Tasks: Configure Task
or on older versions Configure Task Runner
. Selecting it will open the tasks.json file. Delete the script displayed and replace it by the following:
{
"version": "0.1.0",
"command": "explorer",
"windows": {
"command": "explorer.exe"
},
"args": ["test.html"]
}
Remember to change the "args" section of the tasks.json file to the name of your file. This will always open that specific file when you hit F5.
You may also set the this to open whichever file you have open at the time by using ["${file}"]
as the value for "args". Note that the $
goes outside the {...}
, so ["{$file}"]
is incorrect.
Save the file.
Switch back to your html file (in this example it's "text.html"), and press ctrl + shift + b to view your page in your Web Browser.
VS Code has a Live Server Extention that support one click launch from status bar.
Some of the features:
@InvisibleDev - to get this working on a mac trying using this:
{
"version": "0.1.0",
"command": "Chrome",
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
]
}
If you have chrome already open, it will launch your html file in a new tab.
Open Extensions Sidebar (Ctrl + Shift + X)
Search for open in browser and install it
Right click on your html file, and select "Open in Browser" (Alt + B)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With