Can Visual Studio Code use Emmet completion in raz

2019-04-03 17:35发布

问题:

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" }