Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: Treat other extensions as HTML

For the purposes of syntax highlighting and colouring and intellisense is it possible to treat other extensions (tpl, master, etc) as HTML?

I know it's possible on a file by file basis by pressing CTRL+SHIFT+P and selecting "Change Language Mode" BUT I want it to work off file extension, and not have to redo it every time I open a new file.

I also know it's possible for some languages by editing the json files in the plugins directory, BUT there doesn't seem to be one for HTML.

like image 960
mutex Avatar asked Jun 04 '15 23:06

mutex


People also ask

How do I associate an extension in VS Code?

Go to File > Preferences > Settings. Search "File associations" Click on "Add Item"


1 Answers

Update for VS Code 1.0:

There is a setting files.associations that can be used to assign file patterns to languages. For example:

"files.associations": {   "*.tpl": "html",   "*.master": "html" } 

Previous answer:

This is a commonly asked feature request and we are looking into this issue for the future.

As a workaround if you need to have a solutio now:

  • close VS Code
  • open C:\Users\<your name>\AppData\Local\Code\app-<latest-version>\resources\app\server\lib\mime.js
  • find the object literal knownTextMimes
  • for the file extension you want add the proper mime type
  • for example '.tpl': 'text/html'
  • save and restart code

Note: this change will not survive automatic updates but the hopes are that there is a better solution in the future update :)

like image 200
Benjamin Pasero Avatar answered Sep 19 '22 03:09

Benjamin Pasero