What are the keyboard shortcuts to comment code in Android Studio?

What are the keyboard shortcuts for commenting code in Android Studio, for either one line or multiple selected lines //,

//Comentar lineas seleccionadas 1
//Comentar lineas seleccionadas

As for a selected code block /* */.

/*Comentar lineas seleccionadas
  Comentar lineas seleccionadas
  Comentar lineas seleccionadas*/
 5
Author: Carlos Muñoz, 2016-01-17

2 answers

For GNU / Linux

Comment selected Line (s):

Ctrl + /

Comment block of selected Code:

Ctrl + Shif +/


For Windows

Comment selected Line (s):

Ctrl + /

Comment block of selected Code:

Ctrl + Shif +/


For MAC

Use Cmd instead of Ctrl followed by the rest of the keys.


Notes: to override comments the same shortcuts, if they are active they are disabled and if they are disabled they are activated.

Info: http://developer.android.com/sdk/installing/studio-tips.html#q=keymap

You can query which is defined for in your environment:

File >> Settings > KeyMap

enter the description of the image here

By clicking on the defined teclas/shortcut you can change, remove or add them if they are not defined.

enter the description of the image here

 10
Author: Angel Angel, 2020-06-11 10:54:57

If you want to use the atajos del teclado to generate comments that will be for, generate the documentation of functions, methods, classes etc.. you put yourself on the top line and write /** + Enter will automatically generate the following pattern.

Example:

Home:

/** + EnterKey
public void myCar(String name, String color){
//tú código
}

Result:

/**
* @param name
* @param color
*
/
public void myCar(String name, String color)
{
//tú código
}
 6
Author: Webserveis, 2016-01-17 21:48:06