Automatically format code in Visual Studio Code

You can choose one of the below options

"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.formatOnSave": false

Or create a custom keyboard shortcut by editing editor.action.formatDocument. But I AFAIK there is no option to execute the command whenever you press ;. You can set a keyboard shortcut, but I guess you're not able to write ; anymore then :D


To open your user and workspace settings, use the following VS Code menu command:

On Windows/Linux - File > Preferences > Settings

On macOS - Code > Preferences > Settings

Add these options to the editable panel of your configuration settings:

"editor.formatOnPaste": true,
"editor.formatOnSave": true

enter image description here


I was trying to find the answer to the semicolon format thing, because it was doing it on my old computer but not my new one. You just have to change editor.formatOnType = true in your JSON config settings.