78

There is a way in WebStorm to comment or uncomment a specific line or selected block of source code with shortcut?
I tried to use CTRL + / but it doesn't work for me.

Pang
  • 9,564
  • 146
  • 81
  • 122
Max Power
  • 791
  • 1
  • 5
  • 7

16 Answers16

97

Try to use:
Ctrl+/ for Line Comment
or
Ctrl+Shift+/ for Block Comment
or
Set you own keyboard shortcut in Settings from File -> Settings... -> Keymap.
Then search for "comment".

Note: It's the numpad / that works.

References:
https://www.jetbrains.com/help/idea/mastering-keyboard-shortcuts.html

Ola Ström
  • 4,136
  • 5
  • 22
  • 41
Irrech
  • 1,277
  • 2
  • 13
  • 18
  • 2
    Thanks i change this in settings page – Max Power Aug 01 '17 at 07:59
  • 1
    Thanks for showing how to change it in the Keymap settings. On thing bugs me: When I comment a line, the cursor jumps to the next line. Is there a way to let the cursor stay on the same line? – John Archer Jun 12 '20 at 08:39
52

Use CTRL+/, but with the / located on the numpad.

The question remains why commenting with / (the one besides .) does not work (it does not for me, either).

Balint G.
  • 562
  • 5
  • 13
9

On a Mac with an extra keyboard it is CMD + Numpad's /.
The one on the native Macbook keyboard I did not get to work.
Check this post as well: Intellij comment shortcut opens help tab on the Mac menu bar

Dirk Schumacher
  • 1,479
  • 19
  • 37
9
  1. Ctrl + / ==> To comment/uncomment a line .
  2. Ctrl + Shift + / ==> To comment/uncomment block of code.
  3. Ctrl + Y ==> To delete a line.
Mig82
  • 4,856
  • 4
  • 40
  • 63
Vadiraj S J
  • 639
  • 10
  • 17
9

On Windows with a German keyboard layout the default keyboard shortcut for the comment lines action Ctrl+/ conflicts with the bookmark shortcut Ctrl+7. You need to remove the keyboard shortcut for bookmarks in order to get this to work.

SpaceTrucker
  • 13,377
  • 6
  • 60
  • 99
6

If Ctrl + Shift + / doesn't work , try Ctrl + Shift + Num Pad /. You can check the exact configuration in settings->keymap.

Mig82
  • 4,856
  • 4
  • 40
  • 63
pinaci
  • 353
  • 4
  • 4
6

@Note Shortcut IntelliJ IDEA

  • Ctrl + / => comment or uncomment a line -> //
  • Ctrl + shift + / => comment or uncomment block of code -> /**/
  • Ctrl + y => delete a line
  • Ctrl + d => duplicate a line
Mig82
  • 4,856
  • 4
  • 40
  • 63
sleepy
  • 59
  • 1
  • 3
4

I have an AZERTY keypad in French, so this was the answer for me :

Ctrl + Shift + / on the numpad

Because / out of the numpad was detected as :, even with Caps Lock on.

You can check how the keystrokes are actually detected by IntelliJ in :

On Windows : Settings > Keymap > click on the icon of Magnifying glass with cubes (tooltip is "Find Actions By Shortcut"). In the little tooltip that opens, you stroke the keys and observe the registered results.

On Ubuntu : Settings > Keymap > click on the icon of Keyboard, right next to the search input (tooltip is "Find Actions By Shortcut"). In the little tooltip that opens, you stroke the keys and observe the registered results.

ToddEmon
  • 1,140
  • 1
  • 12
  • 16
3

Commenting out each line of selected code for Mac users without numpad would have to add a keyboard shortcut:

  1. Navigate to settings: Preferences > Keymap > Main menu > Code
  2. Double click on Comment with Line Comment
  3. Insert your shortcut, for example: cmd + shift + 7 would be interpreted as shift + cmd + 7 but works the same.
Raimo Johanson
  • 246
  • 2
  • 6
1

You need to activate this option:

  • 'Settings' > 'Keymap' > 'Use national layouts for shortcuts (requires restart)'

Screenshot

Owen Kelvin
  • 14,054
  • 10
  • 41
  • 74
Kocher
  • 11
  • 1
1

As said before on Mac Montery 12 on Idea 2020.3

CMD + NumPad /

or from Action dialog:

enter image description here

0

It is necessary to switch to the English layout

glu
  • 79
  • 6
0

its possible to use inellij IDEA by the way you customized before with an IDE like VisualStudio Settings -> KeyMap -> Choose your old IDE its a grate! feature life saver :)

Hamit YILDIRIM
  • 4,224
  • 1
  • 32
  • 35
0

try ctrl + shift + 7 or num lock and then ctrl + /

  • This answer does not contribute anything new to the topic. Please check the other answers to see if your answer offers any new information before posting – H3AR7B3A7 Jul 08 '22 at 20:07
0

control + / (this is the mathematical one which is located on the numbad)

Ghader
  • 1
  • 1
0

Use the English keyboard, the problem will be solved easily

  • HI @Hamid Hamid Abulqasemi, your answer seems to be unclear. Please explain in little more detail. https://stackoverflow.com/help/how-to-answer – Mearaj Jun 20 '23 at 19:26