[英]HTML files recognized as Django Template in VS Code
在 VSCode 的 settings.json 中包含以下設置emmet.includeLanguages": {"django-html": "html"}
行:
{
"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"
}
}
它在 1.33.1 版上為我修復了
解決了! 我開始消除擴展,發現 Django Template 1.2.0 ( bibhasdn.django-html
) 是罪魁禍首。 一旦我禁用它,HTML 選項就會返回到語言關聯菜單。 給@ifconfig 的帽子提示以確認我應該期望它存在。
這些設置在 vscode settings.json 中對我有用
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements",
"*.html": "html"
},
"emmet.includeLanguages": { "django-html": "html" }
包含 DJANGO 包的 Python 擴展包使 VSCOde 將所有 html 視為 Django 模板並將注釋設置為 {%comment%} 而不是<!-- -->
刪除它解決了問題。
我認為最簡單的方法是檢查這個。 在 vs 代碼的右下角,您可以看到如下圖所示的頁腳。
因此,單擊那里的Django HTML 。 然后可以注意到一個帶有輸入的彈出窗口。 輸入HTML作為輸入並選擇HTML 。 問題解決了。
只需將此添加到您的 Settings.json 中:
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements",
"*.html": "html"
},
"emmet.includeLanguages": { "django-html": "html" }
打開語言(標識符)菜單( press right Ctl
+ K
然后釋放它們並按`M),應該有 HTML。
最后選擇HTML
並重新啟動 VSCode。
要將擴展名映射到settings
搜索結果中的association
中的語言,應該有Files:Associations
:
您可以在其中添加新的key/value
對。 其中key
是擴展名(文件名擴展), value
是語言標識符。
通常 .html 和 .txt 文件被文本編輯器識別為 Django 模板文件。 這可以通過在 VSCode 的 Setting.json 文件中添加給定代碼來解決:
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements",
"*.html": "html"
},
轉到 settings.json,然后
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements",
"*.html": "html"
},
把這個
"emmet.includeLanguages": {
"django-html": "html"
},
像這樣:
{
"workbench.colorTheme": "Default Dark+",
"editor.fontSize": 15,
"window.zoomLevel": -1,
"files.autoSave": "afterDelay",
"files.associations": {
"**/templates/*.html": "django-html",
"**/templates/*": "django-txt",
"**/requirements{/**,*}.{txt,in}": "pip-requirements",
"*.html": "html"
},
"emmet.includeLanguages": {
"django-html": "html"
},
"[django-html]": {
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
}
}
打開你的 VSCode JSON 設置並添加這些行
"files.associations": {
"*.html": "html"
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.