Reputation: 231
Update:
Not sure what happened to my Visual Studio Code installation, but removing and re-installing the application (via homebrew) fixed the problem. Shift - Option - F once again formats code!
I'm struggling to format code in Visual Studio Code on MAC OSX El Capitan.
For some reason the default key binding ('Shift + Option + F') does not work. I also no longer have the option to format code via the 'Command + Shift + P', and entering '>format code'. In fact, '>format code' isn't even an option in the list anymore.
This used to work, but I am not sure what changed.
'Shift + Option + F' does do something though, it makes a ' ̰' character appear that results in some weird cursor behaviour (not sure how else to describe it) when moving over characters adjacent to the ' ̰' character.
Additional information:
Upvotes: 22
Views: 13676
Reputation: 41
on mac keyboard type US International - PC screws up few characters like the usual shift + 6 "^" is replaced with "ˆ" , i set it to just US from ABC India and it worked fine
Upvotes: 3
Reputation: 1571
Solution
If your input sources are other than ABC (eg ABC - India) that might be the source of this issue.
Upvotes: 21
Reputation: 11
If the 'Format Document' shortcut(option+shift+F) is not working on your MAC you can try right-clicking and then using the format document option.
Still, it is mostly because your text input is set to a different keyboard layout such as British, Indian, etc. You need to change your default to U.S.
To change your text input goes to your mac setting>search keyboard>Text Input>InputSources>Edit>then use + sign to add US layout and use - to remove other ones.
Hope it works fine after that.
Upvotes: 1
Reputation: 625
I came from Windows to Mac as a newbie, expecting the most basic things like code formatting would work with Shift+ALt+F as it does on Windows. But naturally, it didn't. The problem was, Keyboard - Input Source (Default in India - [ABC - India]) doesn't capture Shift+Alt+F, which was evident in the "Command Palette: Developer: Toggle Keyboard Shortcuts Troubleshooting"
Solution:
Upvotes: 58
Reputation: 2019
I had the same issue and realized that there was a fixed for that. VS Code repo has a closed issue for that and this may explain why your issue was fixed after reinstalling.
This is the link for the question on the VS Code repo:
https://github.com/Microsoft/vscode/issues/11810
Upvotes: 1
Reputation: 287
It's happening from time to time in my mac and if I just restart VScode it works again. Give it a try before reinstalling it the next time
Upvotes: 1
Reputation: 429
I had the same problem. January 2016 Visual Studio Code release had preliminary support for Salsa. In order to use that you had to install Typescript 1.8 and add typescript.tsdk setting like:
// Specifies the folder path containing the tsserver and lib*.d.ts files to use.
"typescript.tsdk": "./node_modules/typescript/lib"
February 2016 Visual Studio Code release does not need that anymore as Salsa is default anyway. Removing typescript.tsdk setting enabled code format functionality again for me.
Upvotes: 0
Reputation: 1682
I am glad you were able to solve your own problem!
Often a simple reinstall can fix a lot of odd issues with various programs. Depending on what version you were on, updates can also fix bugs that might have caused the issue.
Upvotes: 0