Unable to comment a block of code in Android Studio

21,944

Solution 1

The problem is that the binding is to the main character on the key, which on your keyboard is 7, not /. As I commented before, you might want to try if pressing the Ctrl- works (that is the location of / on my US International keyboard).

Otherwise, I'd suggest you map it to another combination. I don't have Android Studio, but in IntelliJ IDEA (which has the same foundation as Android Studio) this can be configured under File, Settings, Keymap (Main Menu > Code > Comment with Line Comment) or just search for line comment.

Solution 2

Here is the / key on your Yoga 2 Pro Keyboard.

You can usually comment code by using Ctrl-/ or Ctrl-Shift-/

Share:
21,944
Kenneth
Author by

Kenneth

Updated on October 22, 2020

Comments

  • Kenneth
    Kenneth over 3 years

    It seems I'm unable to comment out blocks of code in Android Studio using the CTRL + SHIFT + 7 (on my Lenovo Yoga 2 Pro there's no Numpad and hence no / character on its own button).

    Pressing the above combination creates a bookmark with the number 7 instead.

    Does anyone know a workaround or am I just stuck with /* *\?

  • Kenneth
    Kenneth almost 10 years
    I have a danish keyboard and it looks different that what you're linking too. Here's my keyboard: [IMG]i58.tinypic.com/2vn2h6p.jpg[/IMG]
  • Kenneth
    Kenneth almost 10 years
    Thank you.. I know how to use the keyboard.. Wauw.. You set the bar low.. Shift + 7 draws a / on the screen... Therefore CTRL + shift + 7 should enable commenting of code blocks. But it doesn't. I have linked my keyboard layout further up
  • Kenneth
    Kenneth almost 10 years
    According to the IntelliJ docs CTRL + / or CTRL + shift + / should allow for commenting code blocks.. I can only press CTRL + shift + 7 which should be the equivalent of CTRL + /
  • Kenneth
    Kenneth almost 10 years
    IntelliJ support team has confirmed that my keyboard layout is not currently supported and that I should remap the hotkey. CTRL + - hides the code block. Thank you.
  • Plot
    Plot over 9 years
    I cannot believe that only american keyboards are supported… omg this makes me so angry
  • Mark Rotteveel
    Mark Rotteveel over 9 years
    @Plot technically the problem is not that "only american keyboards are supported". Mapping of shortcuts happens to the main key value (the value you yet get without any modifier). So if the current shortcut is mapped to a value that is not a main key value, then the shortcut won't work and will need to be remapped; something which is fully supported!
  • Halil
    Halil almost 9 years
    I have a Turkish keyboard. CTRL + SHIFT + . worked for me.
  • kike
    kike about 6 years
    @Kenneth, maybe you could create an answer for remapping the hotkey.