First install Prettier -Code formatter [code formatter] in code
The second step is to open it in the menu bar Settings
The third step is to search prettier in the search bar, click to edit in settings
The fourth step is to add one Statement for formatting code when saving
"editor.formatOnSave": true
If an error occurs, it may be in the previous one There is no comma at the end of the statement
Just add it
Recommended related articles and tutorials: vscode tutorial
The above is the detailed content of vscode automatically formats code. For more information, please follow other related articles on the PHP Chinese website!