33

I'm a long time visual studio developer and am stating with VS Code.

I found the Format Code shortcut (Shift + Alt + F) but I want it to run automatically whenever I press ;. Is there a configuration for that?

3 Answers 3

26

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

Sign up to request clarification or add additional context in comments.

3 Comments

Could you add to your answer how to change those settings?
You can find how to change settings in the official documentation: code.visualstudio.com/docs/getstarted/settings
This was written for React but it works for all levelup.gitconnected.com/…
12

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

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.