[atom-editor] Commenting out code blocks in Atom

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?

This question is related to atom-editor

The answer is


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


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.


You can use Ctrl + Shift + / for Windows.


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!


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


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.


Also, there are packages:


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


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 */


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..


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


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


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


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)