这个问题在这里已经有了答案:
How to exclude file extensions and languages from “format on save” in VSCode?
(5 个回答)
2年前关闭。
使用 Visual Studio Code,是否可以禁用特定文件(或扩展名)的格式?
我尝试使用一些 Handlebars 模板,但我根本不希望 VSCode 对它们进行格式化。一个简单的例子是:
{{test1}}
{{test2}}
当我保存这个文件时(我确实有 - 并且想要 -
"editor.formatOnSave"
设置为 true
),VsCode 将内容转换为 {{test1}} {{test2}}
我发现文件保持不变的唯一方法是将其命名为“
template.txt
”而不是“template.hbs
”。任何的想法?
最佳答案
您可以像这样添加特定于文件的排除项:
"[handlebars]": { "editor.formatOnSave": false },
关于handlebars.js - VSCode : disable formatting of a specific file (or extension),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41781045/