Search code examples
htmlvisual-studio-codeformattingidenunjucks

Formatting HTML with Nunjucks extension installed


I have some Angular component HTML some.component.html that I'm trying to format. When I hit ctrl-shiftp, and selectFormat Document` I get the message:

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

So it seems VSCode thinks that the .html file is a nunjucks file.

Is there a way to make it think that it's a html file?


Solution

  • You can switch back to HTML by clicking on the word "Nunjucks" in VS Code's status bar. This "Language Indicator" is near the bottom-right of VS Code's window. Clicking it will display a "Select Language Mode" drop-down-list where you can select "HTML".

    After that, things that normally work for HTML files (like Format Document) will work again; however, things like the special syntax highlighting applied to Nunjuck files will not, but you can switch back and forth as needed.

    Here's VS Code's documentation for Changing the language for the selected file.