9

I have an Apple keyboard (Norwegian) with numeric keypad and I can't get the Xcode shortcut for comment selection (cmd + /) to work. I have to change to Input source = US every time I want to comment out a block. When I change from US to Norwegian input source the Xcode -> Editor -> Structure -> comment selection shortcut disappears.

Does anyone know why changing input source from Norwegian/Swedish/German (I guess all European languages) have this effect. What is the "European" shortcut for comment selection ?

Are Europeans not allowed by Apple to comment select..!? ;-)

Any ideas would be much appreciated !

enter image description here

enter image description here

enter image description here

3 Answers 3

12

You can fix this by going to System Preferences > Keyboard > Shortcuts, then App Shortcuts. Click the + button and select Xcode from the top drop bar. Then set the Menu Title to Comment Selection. Next select the keyboard shortcut box and press the desired keyboard combination, then click OK.

It seems that the Norwegian keyboard's encoding of the / character does not work in shortcuts, so you should use something else than the /

enter image description here

6
  • Unfortunately i tried this, and it does not work, nothing change. Xcode -> Editor -> Structure -> comment selection shortcut is still blank
    – KML
    Commented Nov 4, 2015 at 14:17
  • 1
    @karlml Make sure that Comment Selection is correctly spelled and capitalized. Then, restart Xcode. If it is blank, try using the shortcut anyway. If it doesn't work either, use a different key combination
    – John K
    Commented Nov 4, 2015 at 14:19
  • Ok, this is very odd. If I changed to CMD + * it works... and I get cmd* in the menu Why can I not use cmd+/ ? (I also had to add the same key combination for Uncomment Selection)
    – KML
    Commented Nov 4, 2015 at 14:26
  • @karlml I think it is something to do with the encoding. Maybe the / is a different character on the Norwegian keyboard. There are 3 Norwegian keyboards with seemingly the same input. Try the PC one
    – John K
    Commented Nov 4, 2015 at 14:35
  • Hmm, well it looks the same, and it types the same, and if I type // in Xcode with that button, the code is certainly commented out. But maybe ISO standard have it recognised as something else, or apple have the keyboard mapped wrong, who knows. Thanks
    – KML
    Commented Nov 4, 2015 at 14:38
1

This worked for me

For xcode 8 ->

sudo /usr/libexec/xpccachectl

restart your computer

3
  • not sure though if it wasn't just restarting computer that helped me; in my case "Editor -> Structure -> Comment Selection" was always disabled whether i had any code selectet or not
    – igrek
    Commented Nov 1, 2016 at 16:06
  • @igrek its possible as xcode is having a lot of problems and some times just restarting it fixes the issue. how ever in my case it never worked unless i executed this command..
    – Adeel
    Commented Nov 2, 2016 at 5:16
  • ok, thanks, I had it reproduced couple more times and the command definitely works. No need to restart a computer, you only need to restart xcode
    – igrek
    Commented Nov 15, 2016 at 9:44
0

I have the same Problem with the German keyboard. It works if I press shift+cmd+/. Probably because without the shift it's cmd+7 and the "/" is activated when you press shift.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .