How do I comment out several lines of text selected in the IDE with a control key combination?
I thought that Ctrl + Alt + C was the cor
MAC QWERTY (US- keyboard layout) without numpad:
Line comment : ⌘ + /
Block comment: ⌘ + ⌥ + /
MAC QWERTZ (e.g. German keyboard layout):
Android Studio Version ≥ 3.2:
Line comment : ⌘ + Numpad /
Block comment: ⌘ + ⌥ + Numpad /
thx @Manuel
Android Studio Version ≤ 3.0:
Line comment : ⌘ + -
Block comment: ⌘ + Shift + -
You can also use regions
. See https://www.myandroidsolutions.com/2014/06/21/android-studio-intellij-idea-code-regions/
Select a block of code, then press Code > Surround With... (Ctrl + Alt + T) and select "region...endregion Comments" (2).
To comment/uncomment one line, use: Ctrl + /.
To comment/uncomment a block, use: Ctrl + Shift + /.
I had the same problem, usually, you have found the shortcut but it doesn't work because you have not a NumPad. Actually, the only one issue I found is to set my own shortcut with the one I suppose should works.
First step, find the IDE shortcuts : cmd + shift + A
enter shortcuts
Second step : Find Comments Shortcut with the finder
Third step : Set your custom shortcut (I suggest cmd + shift + /
or cmd + :
)
Now enjoy, it works on a macBook without NumPad
edit : cmd + shift + : has conflicts
Edit : this both works without conflicts Issue on MacBook
On Mac you need cmd + / to comment and uncomment.
From menu, Code -> Comment with Line Commment. So simple.
Or, alternatively, add a shortcut as the following: