Step:1
Install a Prettier Extension in vs code
Step:2
Navigate to File--> Preference--> Setting--> User--> Text Editor--> formatting
and enable the checkbox (Format on Save)
OR you can press Ctrl+ ` for getting setting page.
Step:3
Then navigate to the setting.Json file. Just above the Formatting text. Open that file and past the below code :
{
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
}
}
This above code auto format the code
If there is any gap please let me know:
No comments:
Post a Comment