Use extension...
Enables auto formatting of the code when you save a file.
Launch Visual Studio Code and Quick Open (Ctrl + P), paste the following command, and press Enter.
ext install format-on-save
https://marketplace.visualstudio.com/items?itemName=gyuha.format-on-save