187
votes

I have been moving from Webstorm and RubyMine to Atom and I really miss a feature from the Jetbrains editors where you select a code block and press CMD + - and it adds language specific comment character(s) to the beginning of each line. (# for ruby. // for js, /* for css etc.).

Is there a built in shortcut for Atom or a package which provides this feature?

15
Someone should have also said how to uncomment a block... - Jimmy R.
@JimmyR. - If you repeat the command from the accepted answer (ctrl+/) it will uncomment. Although how well it works seems to depend on the type of file and whether you're working in an already commented block or not. - Broots Waymb

15 Answers

371
votes

According to this, cmd + / should do it.

And for Windows and Linux, it is ctrl + /.

38
votes

Atom does not have a specific comment-block function, but if you select more rows and then use the normal ctrl-/ (Windows or Linux) cmd-/ (Mac), it will comment all the lines.

19
votes

Command + / or Ctrl + shift + 7 doesn't work for me (debian + colombian keyboard). In my case I changed the Atom keymap.cson file adding the following:

'.editor':
  'ctrl-7': 'editor:toggle-line-comments'

and now it works!

16
votes

Also, there are packages:

14
votes

Pressing (Cmd + /) will create a single line comment. i.e. // Single line comment

Type (/** and press the Tab key) to create a block comment ala

/** * Comment block */

13
votes

with all my respect with the comments above, no need to use a package :

1) click on Atom 
1.2) then ATL => the menu bar appear 
1.3) File > Settings  => settings appear
1.4) Keybindings > Search keybinding input => fill "comment"
1.5) you will see :

keybindings panel in atom editor

if you want to change the configuration, you just have to parameter your keymap file

8
votes

You can use Ctrl + /. This works for me.

6
votes

Multi-line comment can be made by selecting the lines and by pressing Ctrl+/ . and Now you can have many plugins for comments

1) comment - https://atom.io/packages/comment
2) block-comment-lines - https://atom.io/packages/block-comment-lines

better one is block-comment try that..

4
votes

Edit your keymap.cson file and add

Windows

'.platform-win32 .editor':
  'ctrl-/': 'editor:toggle-line-comments'

Mac

'.platform-darwin .editor':
  'cmd-/': 'editor:toggle-line-comments'

Now just highlight the text you want to comment and hit the keybinding.

4
votes

You can use Ctrl + Shift + / for Windows.

2
votes

Atom does not have block comment by default, so I would recommend searching for atom packages by "block comment" and install the one suits to you.

I prefer https://atom.io/packages/block-comment because is has the closest keyboard shortcut to line comment and it works as i need it to, meaning it would not comment the whole line but only the selected text.

line comment: CTRL+/ block comment: CTRL+SHIFT+/ (with the plugin installed)

1
votes

On an belgium keyboard asserted on the mac command + shift + / is the keystroke for commenting out a block.

1
votes

CTRL+/ on windows, no need to select whole line, Just use key combination on line which you want to comment out.

1
votes

first select your block of code then press cmd + / for MacOS

0
votes

Possible reason: watch out for overlapping keybindings. It has happened in my case and deactivated the initial toggle line comment binding:

enter image description here

The Keybindings you can find in the Edit -> Preferences -> Keybindings of the application navbar.

The solution was overriding binding for github:toggle-patch-selection-mode

enter image description here