Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS code Format Code command and shortcut Shift+Alt+F doesn't work

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?

like image 622
Marcos Silva Avatar asked Sep 29 '16 17:09

Marcos Silva


People also ask

Why is VS Code not formatting on save?

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.

How do I enable auto format in VS Code?

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.

How do I add code formatter to VS Code?

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.


1 Answers

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.

See the screenshot

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.

like image 194
Shubham kumar Avatar answered Sep 22 '22 16:09

Shubham kumar