HTML files recognized as Django Template in VS Code

不羁岁月 提交于 2020-12-29 05:12:35

问题


I'm new to VS Code, coming from ST3 and TextMate before that. A bit flummoxed why is HTML not autodetected nor is it offered as a choice of language after clicking on the lower-right language indicator?

I've tried explicitly adding "files.associations": {"*.html": "html"} to the User Settings to no effect.

Running VSCode v1.15.1 on macOS v10.12.6.


回答1:


Include the following line of setting emmet.includeLanguages": {"django-html": "html"} in VSCode's settings.json:

{
"python.jediEnabled": false,
"files.autoSave": "afterDelay",
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": 
"automaticallyOverrodeDefaultValue",
"editor.minimap.enabled": true,
"workbench.colorTheme": "Monokai",
"editor.largeFileOptimizations": false,
"html.format.indentInnerHtml": true,
"html.format.indentHandlebars": true,
"emmet.includeLanguages": {"django-html": "html"},
"[django-html]": {

},
"files.associations": {
    "*.html": "html"
}

}

It does the fix for me on version 1.33.1




回答2:


Solved! I began eliminating extensions and found that Django Template 1.2.0 (bibhasdn.django-html) is to blame. As soon as I disabled it, the HTML option returned to the Language Associations menu. Hat tip to @ifconfig for confirming I should expect it to be present.




回答3:


Python Extension Pack that included DJANGO packages made VSCOde see all html as Django Template and set comments as {%comment%} instead of <!-- -->

Removing it solved the issue.




回答4:


1) Click on "select language mode" from bottom right toolbar.

2) Select "Configure file association for .html" from the dropdown.

3) Select html from the dropdown.

This will remove html file being marked as Django-html every time you create a html document.




回答5:


I think the easiest way is to check this. At the right bottom corner of vs code, you can see a footer as below image.

Image of relevant part of VS Code IDE

So, click the Django HTML there. Then a popup with input can be noticed. Enter HTML as the input and select HTML. Problem solved.




回答6:


These settings worked for me in vscode settings.json

"files.associations": {
    "**/templates/*.html": "django-html",
    "**/templates/*": "django-txt",
    "**/requirements{/**,*}.{txt,in}": "pip-requirements",
    "*.html": "html"
  },
  "emmet.includeLanguages": { "django-html": "html" }


来源:https://stackoverflow.com/questions/46044475/html-files-recognized-as-django-template-in-vs-code

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