在 Visual Studio Code 中格式化 Razor 文件 [英] Formatting Razor Files in Visual Studio Code
问题描述
有没有人有在 VSCode 中格式化 Razor 文件的好方法?我试过让它与 prettify-vscode 和 beautify 一起工作.但在这两种情况下,它都无法分辨出 cshtml 文件.我不想将我的剃刀更改为 html,因为我会失去很多剃刀的特性.
Anyone have a good solution for formatting Razor files inside of VSCode? I've tried making it work with prettify-vscode and beautify. But in both cases it can't tell that cshtml files. I don't want to change my razor to html as I'll lose a lot of the razor-ness.
推荐答案
您可以将它们引入为 HTML 文件(文件 -> 首选项 -> 设置),无需任何 3rd 方扩展:
You can introduce them as HTML files (File -> Preferences -> Settings) without any 3rd party extensions:
{
"editor.formatOnSave": true,
"emmet.includeLanguages": {
"razor": "html"
},
"files.associations": {
"*.cshtml": "html"
}
}
更新:C# for Visual Studio Code
插件的 v1.17.0 添加了预览 Razor (cshtml) 语言服务,支持 C# 完成和诊断.
Update: v1.17.0 of C# for Visual Studio Code
add-on added preview Razor (cshtml) language service with support for C# completions and diagnostics.
这篇关于在 Visual Studio Code 中格式化 Razor 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!