You think good formatting is a virtue.
And you always save your progress while you are coding.
Alright! It's when the editor.formatOnSave
setting of VS Code
saves your life.
But...
Sometimes you are in the middle of writing a dirty code and you just want to conveniently save the file without formatting it, as well as being able to format the document only if you decide to.
Here it comes the format-on-second-save
extension. This extension does a very simple job which we think should be a default VS Code
functionality:
ctrl/cmd + s
on a dirty file just saves the filectrl/cmd + s
on an unchanged file formats and then saves the file
In this way, you have the control of only saving the file by your save shortcut... and you can also format the document by pressing the same shortcut for the second time.
In the official Extensions Marketplace, search for Format onSecondSave
; then click on Install
.
Format onSecondSave on Marketplace
Here comes a tip for the VS Code
dev team:
editor.formatOnSecondSave
is a good name if you decided to add this feature to VS Code
!