Use visual Studio code to open a browser to view HTML files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.