Any clues on why my VS Code "Format Code" command doesn't work? I used Shift+Ctrl+P and entered Format Code or used the shortcut Shift + Alt + F. None seem to be working. Any clue?
Usage. To automatically format the file on save, In Visual Studio Code, press Control + Shift + P or Command + Shift + P (Mac) to open the command palette and type setting and then select Preferences: Open User Settings option. Search for format on save setting and check the checkbox.
Click the “Settings” gear icon in the bottom-left corner. Search “Formatter” and click the “Editor: Default Formatter” option. From the drop-down menu, select whichever code formatter you want to use. Scroll down a bit and check the box next to the “Editor: Format On Save” option.
The code formatting is available in Visual Studio Code through the following shortcuts: On Windows Shift + Alt + F. On Mac Shift + Option + F. On Linux Ctrl + Shift + I.
I guess you are asking for MacOs because by default shortcut for code formatting is different for different Os. Now there might be an issue with the keyboard layout.
For example Option+Shift+F does not work in ABC-Indian layout, you need to change that. Go to System-prefrences->Keyboard->Input Sources-> Add layout "ABC" and delete the old one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With