Can Visual Studio Code use Emmet completion in razor .cshtml files

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 15:33:15

问题


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)

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

I've found:

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

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!

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)?


回答1:


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": { "razor": "html" }



来源:https://stackoverflow.com/questions/46688631/can-visual-studio-code-use-emmet-completion-in-razor-cshtml-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!