VSCode:禁用特定文件(或扩展名)的格式 [英] VSCode : disable formatting of a specific file (or extension)

查看:680
本文介绍了VSCode:禁用特定文件(或扩展名)的格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Visual Studio代码,是否可以禁用特定文件(或扩展名)的格式?

Using Visual Studio Code, is it possible to disable the formatting of a specific file (or extension)?

我尝试使用一些Handlebars模板,但我根本不希望VSCode格式化它们.一个简单的例子是:

I try to use some Handlebars templates and I don't want VSCode to format them, at all. A simple example would be :

{{test1}}

{{test2}}

当我保存此文件时(我确实有-并且想要将"editor.formatOnSave"设置为true),VsCode会将内容转换为

When I save this file (I do have - and want - "editor.formatOnSave" set to true), VsCode transforms the content to

 {{test1}} {{test2}}

我发现文件保持不变的唯一方法是将其命名为"template.txt",而不是"template.hbs".

The only way I found for the file to stay untouched, is to name it "template.txt" instead of "template.hbs".

有什么主意吗?

推荐答案

您可以添加文件特定的排除项,如下所示:

You can add file-specific exclusions like so:

"[handlebars]": { "editor.formatOnSave": false },

这篇关于VSCode:禁用特定文件(或扩展名)的格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆