For year's I've used js-beautify, first in Atom and recently in VS Code using the Beautify extension. Now it looks like that extension has been deprecated, and js-beautify is now built-in VS Code.
But with the extension I could add a .jsbeautifyrc file to specify formatting options, in particular end_with_newline to add a newline at the end of the file. I could even specify file type-specific options.
{
…
"end_with_newline": true,
"wrap_line_length": 0,
"css": {
"selector-separator-newline": false
}
}
When I disable the extension and use the internal VS Code js-beautify, it no longer seems to honor the .jsbeautifyrc settings, and removes the trailing newline.
How do I configure the formatting settings of the internal VS Code js-beautify implementation?
If you search the settings for
css formatyou will see there are a few there: newlines between selectors and rules, etc.So you could disable
CSS > Format: Newlines Between Selectorsfor example.In addition, you can make
css-specific settings like this (in yoursettings.json):And make sure the setting
CSS > Format: Enableis set totrue. (the default istrue)