Visual Studio Code:将其他扩展视为 HTML [英] Visual Studio Code: Treat other extensions as HTML

查看:27
本文介绍了Visual Studio Code:将其他扩展视为 HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于语法突出显示和着色以及智能感知的目的,是否可以将其他扩展(tpl、master 等)视为 HTML?

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

我知道可以通过按 CTRL+SHIFT+P 并选择更改语言模式"来逐个文件地进行,但我希望它可以使用文件扩展名,而不必每次打开新文件时都重做.

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.

我也知道可以通过编辑 plugins 目录中的 json 文件来处理某些语言,但 HTML 似乎没有.

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.

推荐答案

VS Code 1.0 更新:

有一个设置 files.associations 可用于将文件模式分配给语言.例如:

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

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

上一个答案:

这是一个常见的功能请求,我们将在未来调查此问题.

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:

  • 关闭 VS Code
  • 打开C:\Users\<你的名字>\AppData\Local\Code\app-\resources\app\server\lib\mime.js
  • 找到对象字面量 knownTextMimes
  • 对于要添加正确的 MIME 类型的文件扩展名
  • 例如 '.tpl': 'text/html'
  • 保存并重启代码

注意:此更改不会在自动更新中幸存下来,但希望在未来的更新中有更好的解决方案:)

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

这篇关于Visual Studio Code:将其他扩展视为 HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆