问题
I just upgraded to Xcode GM 8.0 and noticed ⌘ + / is not commenting out selected lines. Is there another command to comment out multiple lines in Xcode 8?
回答1:
In Xcode7 and earlier versions, the commenting option was available in Editor > Structure > Comment Selection. In Xcode 8 this option is disabled.
To enable these options run sudo /usr/libexec/xpccachectl
and restart your Mac.
There is thread on Apple Developer Forums regarding this issue and several possible fixes. For me running the above command and restarting the Mac did the fix.
Also in Xcode 8 release note it states:
To use the Editor's Comment/Uncomment Selection and Add Documentation commands—as well as other installed Xcode Extensions—on OS X version 10.11, launch Xcode and install additional system components, then restart your Mac. (26106213)
回答2:
I finally figured this one out, drove me crazy…
These are the preconditions for the bug to arise:
- '/' needs to be accessed with the shift key, like i.e. on German keyboards.
- There is a global OS X hotkey to access help with shift+cmd+'/', which is the default
Under these preconditions there is not conflict showing in XCode keyboard preferences, but it trying to invoke cmd+'/' triggers the global help hotkey anyway.
How to fix it?
Simply remap or switch off the global hotkey to show help in system preferences > keyboard > keyboard shortcuts, select app shortcuts in the list on the left.
回答3:
Go to Systems Preferences > Keyboard > Shortcuts > App shortcuts and disable Show Help menu option.
That worked for me after try with all possible solutions.
回答4:
Sometimes this happens to me (even with Xcode7, and just confirmed still with Xcode8) after opening the documentation window (Help -> Documentation and API Reference or cmd+shift+0). Here are a few things that have fixed it when it was happening to me:
- Restart Xcode (realize you've already tried this, but including it for posterity)
- Close the documentation window
- With only 1 Xcode window open, hit cmd+~ a couple times
- Wish really really hard
回答5:
If you have a nested /* anywhere, including in a string, it breaks the XCode comment command. See details here.
来源:https://stackoverflow.com/questions/39519163/multiple-line-comment-in-xcode-8