In your settings.json add the following
xxxxxxxxxx
{
"editor.formatOnSave": true,
// to do most of the basic formatting you need also add the following
// add as required
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
}
To just add via VSCode settings:
Go to File > Preferences > Settings
Go to Text Editor > Formatting or search for "editor.formatOnSave" Format on save option.
Check the Editor: Format On Save option.
xxxxxxxxxx
//In the setting.json.. check this
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
xxxxxxxxxx
Add the following to your settings.json file:
"editor.formatOnSave": true
You can find your `settings.json` configuration file
in vscode by searching for "settings.json" in the
`Ctrl + Shift + P` search bar.
xxxxxxxxxx
On VSCode:
1) Navigate to File > Preferences > Settings
2) Navigate to Text Editor > Formatting or search for editor. formatOnSave
3) Check the Editor: Format On Save option.
xxxxxxxxxx
Ctrl + Shift + P
Search Setting.JSON
On the setting tab, search format.
Scroll down and check the format on save box.