Visual Studio Code 可以在 razor .cshtml 文件中使用 Emmet 完成吗 [英] Can Visual Studio Code use Emmet completion in razor .cshtml files

查看:89
本文介绍了Visual Studio Code 可以在 razor .cshtml 文件中使用 Emmet 完成吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio Code(1.17.1,在 MacOS 10.13 和 Windows 10 上)使用剃刀模板开发一个 asp.net core mvc web 应用程序.Visual Studio Code 支持 Emmet (https://code.visualstudio.com/docs/editor/emmet)

I'm using Visual Studio Code (1.17.1, on MacOS 10.13 AND Windows 10) developing an asp.net core mvc web app using razor templating. Visual Studio Code supports Emmet (https://code.visualstudio.com/docs/editor/emmet)

我的问题是 Emmet 在 HTML 文件中可以正常工作,但不能在 razor CSHTML 文件中工作.

My issue is that Emmet works correctly in HTML files, but will not work in razor CSHTML files.

我发现:

要在默认情况下不可用的文件类型中启用 Emmet 缩写扩展,请使用 emmet.includeLanguages 设置.确保对映射的双方都使用语言 ID.https://code.visualstudio.com/docs/editor/emmet

To enable the Emmet abbreviation expansion in file types where it is not available by default, use the emmet.includeLanguages setting. Make sure to use language ids for both sides of the mapping. https://code.visualstudio.com/docs/editor/emmet

但它没有指明在哪里可以找到语言 ID"列表.我试着搜索它,但你可以想象当你搜索编程语言 id 时会发生什么!

but it doesn't indicate where to find a list of "language ids". I tried searching for it, but you can imagine what happens when you search for programming language id!

有没有办法告诉 VS Code 中的 Emmet 将 cshtml 文件视为 html 文件?有没有其他方法可以让它工作(除了重命名文件,这是另一种解决方案)?

Is there a way to tell Emmet in VS Code to treat cshtml files as html files? Is there any other way to get this to work (besides renaming the files, which is another solution out there)?

推荐答案

根据此链接,*.cshtml文件对应的语言是razor,因此需要在emmet mappings中指定如下:

According to this link, the corresponding language for *.cshtml files is razor, thus you need to specify it in the emmet mappings as follows:

<代码>emmet.includeLanguages":{剃刀":html"}

这篇关于Visual Studio Code 可以在 razor .cshtml 文件中使用 Emmet 完成吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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