Automatic code format in VSCODE

I have been a visual studio developer for a long time and am stating with VSCode.

I found the "Code Format" shortcut (Shift + alt + f), but I want it to start automatically whenever I hit ';'. Is there a configuration for this?

+3


source to share


2 answers


You can choose one of the following 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 way to execute the command whenever you click ;

. You can set the keyboard shortcut, but I guess you can't write anymore ;

: D

+5


source


To open User and Workspace Options , use the following VS Code menu command:

On Windows / Linux - File> Preferences> Preferences

On macOS - Code> Preferences> Preferences

Add these parameters to the editable configuration options panel:



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

      

enter image description here

0


source







All Articles