[英]Prettier extension in VS code is not working, I tried everything including yt tutorials and what ever i did nothing helped
im desperate, finaly made myself study some react and guess what, cant even start cuz suddenly my settings are messed up.我绝望了,最后让自己研究了一些反应并猜猜是什么,甚至无法启动因为突然我的设置搞砸了。 When ever I try to save to auto format nothing happens.每当我尝试保存为自动格式时,什么都没有发生。 I really tried everything from here on stackoverflow and even yt but nothing really helped...Gonna show you my code: this is how it looks like after I press ctrl+s to save the file and to format it...我真的在 stackoverflow 甚至 yt 上尝试了这里的所有内容,但没有任何帮助...将向您展示我的代码:这是我按 ctrl+s 保存文件并格式化后的样子...
Like a week ago everything worked well and somehow I messed up the settings.就像一周前一样,一切都运行良好,不知何故我搞砸了设置。 Would be helpful if someone sent me his settings.json because Ive tried some Ive found on google and none helped.如果有人向我发送他的 settings.json 将会很有帮助,因为我尝试了一些我在谷歌上找到的但没有帮助。 I really wanna study React but this wont let me.我真的很想学习 React,但这不会让我。 I know I can use codesandblox but its not it...Thx in advance...我知道我可以使用codesandblox,但不是它......提前谢谢......
You need to set your default formatter to Prettier and enable format on save.您需要将默认格式化程序设置为 Prettier 并在保存时启用格式化。
Default Formatter To ensure that this extension is used over other extensions you may have installed, be sure to set it as the default formatter in your VS Code settings.默认格式化程序为确保此扩展程序用于您可能已安装的其他扩展程序,请务必在 VS Code 设置中将其设置为默认格式化程序。 This setting can be set for all languages or by a specific language.可以为所有语言或特定语言设置此设置。 The following will use Prettier for only Javascript.以下将仅对 Javascript 使用 Prettier。
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
Format On Save Respects editor.formatOnSave setting.格式保存尊重 editor.formatOnSave 设置。
You can turn on format-on-save on a per-language basis by scoping the setting:您可以通过限定设置的范围,在每种语言的基础上启用 format-on-save:
// Set the default
"editor.formatOnSave": false,
// Enable per-language
"[javascript]": {
"editor.formatOnSave": true
}
{
"git.autofetch": true,
"terminal.explorerKind": "external",
"files.autoSave": "afterDelay",
"terminal.integrated.profiles.windows":{"Git Bash":{"path":"C:\\Program Files\\Git\\bin\\bash.exe"}, },
"terminal.integrated.defaultProfile.windows": "Git Bash",
"editor.formatOnSave": true,
"html.format.indentHandlebars": true,
"html.format.indentInnerHtml": true,
"settingsSync.ignoredExtensions": [
],
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.