[英]How to stop vscode beautify or prettier from preserving newlines when formatting javascript code?
I want to remove all the newlines/extra lines when I save the code.我想在保存代码时删除所有换行符/额外行。 I found this settings in Atom but not in VSCode.
我在 Atom 中找到了这个设置,但在 VSCode 中没有。 How can I do that?
我怎样才能做到这一点?
You can set the VSCode setting html.format.preserveNewLines
to false
.您可以将 VSCode 设置
html.format.preserveNewLines
设置为false
。 It will be recognized by Beautify, but works only for HTML files.它将被 Beautify 识别,但仅适用于 HTML 文件。
The alternative to apply the setting for all files recognized by Beautify is to add a file named .jsbeautifyrc
at the root of the workspace, with the following content:对 Beautify 识别的所有文件应用设置的另一种方法是在工作区的根目录添加一个名为
.jsbeautifyrc
的文件,其内容如下:
{
"preserve_newlines": false
}
Also, the VSCode setting editor.formatOnSave
should be set to true
.此外,VSCode 设置
editor.formatOnSave
应设置为true
。 To do it you can create the file .vscode/settings.json
with the next content:为此,您可以使用下一个内容创建文件
.vscode/settings.json
:
{
"editor.formatOnSave": true
}
The settings.json
file, located at the .vscode
folder in the root of the workspace, allows to configure the VSCode settings to be applied for the current workspace. settings.json
文件位于工作区根目录的.vscode
文件夹中,允许配置要应用于当前工作区的 VSCode 设置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.