Comment shortcut Android Studio

Android StudioKeyboard Shortcuts

Android Studio Problem Overview


I'm searching for useful Android Studio keyboard shortcut for commenting code, as in Sublime Text or Eclipse.

When I press either cmd+/ or cmd+maj+/ nothing happens...

Android Studio Solutions


Solution 1 - Android Studio

Mac With Numeric pad

Line Comment hold both: Cmd + /

Block Comment hold all three: Cmd + Alt + /

Mac

Line Comment hold both: Cmd + + =

Block Comment hold all three: Cmd + Alt + + =


Windows/linux :

Line Comment hold both: Ctrl + /

Block Comment hold all three: Ctrl + Shift + /

Same way to remove the comment block.


To Provide Method Documentation comment type /** and press Enter just above the method name (

It will create a block comment with parameter list and return type like this

/**
 * @param userId 
 * @return
 */
public int getSubPlayerCountForUser(String userId){}

Solution 2 - Android Studio

In spanish keyboard without changing anything I can make a comment with the keys:

cmd + -

OR

cmd + alt + -

This works because in english keyboard / is located at the same place than - on a spanish keyboard

Solution 3 - Android Studio

Be sure you use the slash (/) on right side of keyboard.

For Line Comment:

Ctrl + /

For Block Comment:

Ctrl + Shift + /

You can see all keymap in Android Studio: Help ➤ Default Keymap Reference

Solution 4 - Android Studio

On Mac and Turkish Keyboard it is (both for commenting out and uncommenting)

line comment: cmd +.

block comment: cmd+alt +.

Solution 5 - Android Studio

An Example for a Mac OS X 10.5+ with a German layout keyboard without NumPads:

  1. Open Preferences
  2. Search for "Keymap"
  3. Expand "Main menu"
  4. Expand "Code"
  5. Delete all shortcuts (just a suggestion)
  6. Add a shortcut for a single line comment (e.g. Ctrl++)
  7. Add a shortcut for a block comment (e.g. Ctrl+alt +)
  8. This way you can be sure that those keys are not mapped (except if you assigned them before to another function)

enter image description here

Solution 6 - Android Studio

Reviewing and Changing Keyboard Shortcuts in Android Studio

Keyboard shortcuts can be configured (and reviewed) via the Settings dialog, accessible via File -> Settings.

Once this dialog appears, to review (and/or add) a shortcut, do the following:

Modify shortcut dialog

  1. Select Keymap in the list on the left. Note that there is a "Keymaps" option, and depending on the original selection, shortcuts assigned to a given feature differ based on the Keymap.

  2. Type "comment" or text corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned. Each match has a line entry in the list below, and keyboard shortcuts are shown right-justified along with the feature. For example, both CTRL+ALT+SLASH and CTRL+K, CTRL+C are the two assignments for creating a line comment.

To modify a shortcut:

  1. Select the resultant line corresponding to the feature for which the keyboard shortcut is to be reviewed/assigned
  2. Right-click, and select the desired Add or Remove option.

Solution 7 - Android Studio

In Android studio CTRL + SHIFT + / for windows.

Solution 8 - Android Studio

for German Layout (Deutsches Layout) the default is:

for line Comment: strg + Numpad(/)

for block Comment: strg+shift+Numpad(/)

Solution 9 - Android Studio

Comment method like pro developers:

Windows/linux:

> Line Comment : Ctrl + / > > Block Comment : Ctrl + Shift

Method Commenting:

> Type /** and press Enter Key

it will add the comment snippet like we see in standard documentation, give it a try this once.

/**
 * 
 * @param addOpacity
 */
public void setOpacityOnUserImage(boolean addOpacity) {
// Your business logic. 
}

Solution 10 - Android Studio

I use this sequence (not a 'linear' shortcut but useful anyway):

  • alt+c then alt+b (holding alt) for block comment
  • alt+c then alt+l (holding alt) for line comment

(they use the android studio menu)

Solution 11 - Android Studio

On PC it's by default set to Ctrl + /. This will toggle commenting a selection or current line.

Solution 12 - Android Studio

I am working with a german keyboard and the slash (/) is on the 7 key, meaning access would be Ctrl + Shift + 7. However, this does not work as this is predefined as something with bookmark 7.

I went to settings (search for keymap) and deleted all existing shortcuts. I than added Ctrl + 7, confirmed deletion of bookmark shortcut and now can work well.

Solution 13 - Android Studio

For Line Comment: Ctrl + /

For Block Comment: Ctrl + Shift + /

Solution 14 - Android Studio

> For multiline comment in android studio > > select the statement that you want to commented then > > use ctrl+shift+/

and for removing mutiline comment 

select the statement that you want to uncommented then

use **ctrl+shift+/**

> SINGLE LINE COMMENT > > For single line comment > > use ctrl+/

Solution 15 - Android Studio

Ctrl + Shift + / works well for me on Windows.

Solution 16 - Android Studio

In LINUX

1.Single line commenting. Ctrl + /

2.For block comment Ctrl + Shift + /

Solution 17 - Android Studio

on mac, using uk english keyboard layout to reach quickcomment in android studio the key combination is:

> cmd + alt(option) + /

Solution 18 - Android Studio

Are you sure you are using / and not \ ? On Mac I have found by default:

  • Cmd + /

Comments using // notation

  • Cmd + Opt + /

Comments using /* */ notation

Solution 19 - Android Studio

Mac (French-Canadian Keyboard):

Line Comment hold both: Cmd + É

Block Comment hold all three: Cmd + Alt + É

"É" is on the same position as "?/" in english one.

Solution 20 - Android Studio

If you are used with Eclipse, there is something in Settings>Keymap Keymaps: and you can pick Eclipse to keep the same shortcuts.

Solution 21 - Android Studio

In android studio you can do single comment with (go to line then Ctrl+/) and block comment with ( select text then Ctrl+Shift+/)

Also if you want to change color of commented text go to File->Settings->IDE settings->Editor->Color & fonts->Java->(Line comment or block comment) and change properties. I prefer it to be green which is used in notepad++ editor.

Solution 22 - Android Studio

For Line Comment hold both:

Ctrl + /

For Block Comment hold all three:

Ctrl + Shift + /

Same way to remove the comment block.

Solution 23 - Android Studio

In the Icelandic MAC keyboard: CMD + -

Solution 24 - Android Studio

You can add three slashes.

/// Add comments

this can clear the "comment out code 2 lines" issues.

Solution 25 - Android Studio

Mac:

To comment/uncomment one line, use: Ctrl + /.

To comment/uncomment a block, use: Ctrl + Shift + /.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHugo GresseView Question on Stackoverflow
Solution 1 - Android StudioHugo GresseView Answer on Stackoverflow
Solution 2 - Android StudiojdivinsView Answer on Stackoverflow
Solution 3 - Android StudioAhmet ArslanView Answer on Stackoverflow
Solution 4 - Android StudioBurcak KamView Answer on Stackoverflow
Solution 5 - Android StudioMustafa YousefView Answer on Stackoverflow
Solution 6 - Android StudioCJBSView Answer on Stackoverflow
Solution 7 - Android StudioBelloSoftView Answer on Stackoverflow
Solution 8 - Android StudioPKAPView Answer on Stackoverflow
Solution 9 - Android StudioRishabh SaxenaView Answer on Stackoverflow
Solution 10 - Android StudioocrampicoView Answer on Stackoverflow
Solution 11 - Android StudioJay WickView Answer on Stackoverflow
Solution 12 - Android StudioGunnar BernsteinView Answer on Stackoverflow
Solution 13 - Android StudioRishabh SaxenaView Answer on Stackoverflow
Solution 14 - Android Studiorajeev omarView Answer on Stackoverflow
Solution 15 - Android StudioAsim GasimzadeView Answer on Stackoverflow
Solution 16 - Android StudioRameshView Answer on Stackoverflow
Solution 17 - Android StudioBenjamin PappView Answer on Stackoverflow
Solution 18 - Android StudioJames AlvarezView Answer on Stackoverflow
Solution 19 - Android StudioIdaliView Answer on Stackoverflow
Solution 20 - Android StudiopetrumoView Answer on Stackoverflow
Solution 21 - Android Studioajax DView Answer on Stackoverflow
Solution 22 - Android StudioRoman Polen.View Answer on Stackoverflow
Solution 23 - Android StudioHandel 38View Answer on Stackoverflow
Solution 24 - Android StudioTechalgowareView Answer on Stackoverflow
Solution 25 - Android StudioRavirajView Answer on Stackoverflow