保存时Visual Studio代码格式失败 [英] Visual Studio Code Formatting fail on save

查看:166
本文介绍了保存时Visual Studio代码格式失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习React Native.

I've started learning React Native.

我正在使用Visual Studio Code作为编辑器.

I'm using Visual Studio Code as my editor.

我已经设置好样板并启动了应用程序.但是,每当我更改一个.js文件并点击保存时,VSCode就会弄乱所有格式.

I've set up the boiler plate and started the app. But whenever I change a .js file and hit save, VSCode is messing up all the formatting.

我以为我可以在settings.json文件中对它进行排序,但是在谷歌搜索了一会儿之后,我找不到正确的设置.

I thought I could sort this in the settings.json file but after googling for a while and playing around I can't find the correct setting.

这是错误还是我做错了什么?

Is this a bug or am I doing something wrong?

设置文件为默认文件之一:

Setting file is default one:

更新:我重新安装了vscode.然后设置一个带有react native标签和html标签的基本js文件.我添加了:

UPDATE: I re-installed vscode. Then set up a basic js file with a react native tag and a html tag. I added in:

"editor.formatOnSave": false,
"javascript.format.enable": false

到我的settings.json文件,问题仍然出现:

To my settings.json file and the problem still occurs:

问题在于js文件中有标签,我只是不知道如何告诉vscode忽略它们?

The problem is having tags in a js file, I just don't know how to tell vscode to ignore them?

推荐答案

通过查看扩展名,我发现了这是什么.感谢@wgj的提示.

I found out what this was by looking though the extensions. Thanks to @wgj for the hint.

原来是JS-CSS-HTML格式化程序.我仔细阅读了说明,并暂时删除了自动保存功能.我将为此制定特定的设置.

Turns out it was the JS-CSS-HTML formatter. I looked through the instructions and have removed the auto save for now. I'll have to work out the specific settings for this.

它使用js-beautify,因此如果有人知道我应该查看的设置,将不胜感激.

It uses js-beautify so if anyone knows the settings I should be looking at would be much appreciated.

这篇关于保存时Visual Studio代码格式失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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