Use visual Studio code to open a browser to view HTML files
Vscode always use sublime, the latter when writing HTML files can be the right mouse button to find open in browser to start the system default browser, and Vscode does not have this function, debugging and preview is more Troublesome. however, You can fix this problem by configuring the Tasks.json File.
Press ctrl+p to open the command panel , type Tasks.json and enter to open the file, you can see the default configuration, and then modify the Following:
{//See http://go.microsoft.com/fwlink/?LinkId=733558//For the documentation about the Tasks.json format "version": "0.1.0" Chrome ", // Using the Chrome browser "windows" : {"command": " C:/Program Files (x86)/google/chrome/application/chrome.exe " //}, "isshellcommand": true [" ${ file} "] , // means action on the current file "showoutput": "always" }
After saving open an HTML file, press the key combination ctrl+shift+b You can use the specified browser to open the HTML file.
Updates for version 1.8.0
Recently upgraded to 1.8.0, found that the above operation is invalid, and then changed (only to Win):
- first, the interface presses the
Ctrl+Shift+P
Display command panel and entersctr
Select "task: Configure task Run program"
- Then select "Others" to see the default configuration
The last modification is as follows (delete one line):
{ "version": "0.1.0", "command": "Chrome", "windows": { "command": "c:/program Files" ( X86)/google/chrome/application/chrome.exe " },
"isshellcommand": true, "args": ["${file}"], "showoutput": "never"}
Once saved, open the HTML file and press Ctrl+Shift+B
to open the Browser.
In addition to correct the comments in the following comment, the New. Vscode folder is not available, Windows will consider the file name is illegal, This folder can only be created through vscode, which is the above mentioned Steps.
In addition, it is possible to preview the HTML file using a combination of keys above, Ctrl+Shift+V
without opening the browser, but not to a single file with no configuration File.
Use visual Studio code to open a browser to view HTML files