Multiple line comment in Xcode 8

后端 未结 5 1864
说谎
说谎 2021-02-03 18:51

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?

相关标签:
5条回答
  • 2021-02-03 18:58

    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)

    0 讨论(0)
  • 2021-02-03 18:58

    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
    0 讨论(0)
  • 2021-02-03 19:13

    If you have a nested /* anywhere, including in a string, it breaks the XCode comment command. See details here.

    0 讨论(0)
  • 2021-02-03 19:20

    Go to Systems Preferences > Keyboard > Shortcuts > App shortcuts and disable Show Help menu option.

    That worked for me after try with all possible solutions.

    0 讨论(0)
  • 2021-02-03 19:21

    I finally figured this one out, drove me crazy…

    These are the preconditions for the bug to arise:

    1. '/' needs to be accessed with the shift key, like i.e. on German keyboards.
    2. 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.

    0 讨论(0)
提交回复
热议问题