Monday, November 26, 2018

How to Format code in Visual Studio Code

Auto-format your code in Visual Studio Code


If you want to auto-format your code in Visual Studio Code you have to enable the setting.
1.  Go to File > Preferences > Settings

2. In Search, bar enter formatOnSave

3. Checkmark the setting and it will automatically save the setting
4. Close and reopen Visual Studio Code

Format Document of code in Visual Studio Code

1. Double click and open TypeScript or JavaScript document
2. Right click on the document
3. Select Format Document option

Shortcut key to format document is Shift+Alt+F

Format Selection of code in Visual Studio Code

1. Double click and open TypeScript or JavaScript document
2. Select the code you want to format
3. Select Format Selection option

Shortcut key to format document is Ctrl+K Ctrl+F

You are Done!!!

No comments:

Post a Comment