html - 安装 Nunjucks 扩展后设置 HTML 格式

标签 html visual-studio-code formatting ide nunjucks

我有一些正在尝试格式化的 Angular 组件 HTML some.component.html 。当我按下 ctrl-shiftp 并选择Format Document`时,我收到消息:

There is no document formatter for 'nunjucks'-files installed.

看来 VSCode 认为 .html 文件是一个 nunjucks 文件。

有没有办法让它认为这是一个html文件?

最佳答案

您可以通过单击 VS Code 状态栏中的“Nunjucks”一词切换回 HTML。这个“语言指示器”位于 VS Code 窗口的右下角附近。单击它将显示“选择语言模式”下拉列表,您可以在其中选择“HTML”。

之后,通常适用于 HTML 文件的功能(例如格式文档)将再次起作用;但是,诸如应用于 Nunjuck 文件的特殊语法突出显示之类的东西不会,但您可以根据需要来回切换。

这里是 Changing the language for the selected file 的 VS Code 文档.

关于html - 安装 Nunjucks 扩展后设置 HTML 格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53292816/

相关文章:

html - css3中的图像动画

html - 将 <span> 标签定位在侧边 <div> 标签中

python - VS Code UI 语言不会传播到 python 扩展命令面板

postgresql - PostgreSQL-如何将包含秒数的 float 转换为 MM :SS. ss

c# - 将每日事件时间转换为 "Mon-Fri 10:00-10:30AM"格式

python - 使用旧版本的 NumPy 格式化 2D 数组

javascript - 在触摸设备上捕获并停止拖动

html - 具有相同大小的按钮和 div 在 em 中不相等,而在 px 中相等

debugging - 如何在 Visual Studio Code 中调试 C++ 代码

code-formatting - 如何在Windows上的Visual Studio Code中格式化代码