Commenting out code blocks in Atom

Atom Editor

Atom Editor Problem Overview


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?

Atom Editor Solutions


Solution 1 - Atom Editor

According to this, cmd + / should do it.

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

Solution 2 - Atom Editor

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.

Solution 3 - Atom Editor

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!

Solution 4 - Atom Editor

Also, there are packages:

Solution 5 - Atom Editor

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

Solution 6 - Atom Editor

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

Solution 7 - Atom Editor

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

Solution 8 - Atom Editor

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

better one is block-comment try that..

Solution 9 - Atom Editor

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.

Solution 10 - Atom Editor

You can use Ctrl + Shift + / for Windows.

Solution 11 - Atom Editor

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)

Solution 12 - Atom Editor

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

Solution 13 - Atom Editor

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

Solution 14 - Atom Editor

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

Solution 15 - Atom Editor

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

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
QuestionmaxView Question on Stackoverflow
Solution 1 - Atom Editorray hatfieldView Answer on Stackoverflow
Solution 2 - Atom EditorMaxView Answer on Stackoverflow
Solution 3 - Atom EditorandrezView Answer on Stackoverflow
Solution 4 - Atom EditorheilopView Answer on Stackoverflow
Solution 5 - Atom EditorCarlos A. CabreraView Answer on Stackoverflow
Solution 6 - Atom EditormarcdahanView Answer on Stackoverflow
Solution 7 - Atom Editormoon shineView Answer on Stackoverflow
Solution 8 - Atom Editorlearn2codeView Answer on Stackoverflow
Solution 9 - Atom EditorMastergalenView Answer on Stackoverflow
Solution 10 - Atom EditorSufiyan KsrView Answer on Stackoverflow
Solution 11 - Atom EditorungalcrysView Answer on Stackoverflow
Solution 12 - Atom EditorMichal_SzulcView Answer on Stackoverflow
Solution 13 - Atom EditorkenwaldekView Answer on Stackoverflow
Solution 14 - Atom EditorAsifView Answer on Stackoverflow
Solution 15 - Atom EditorSanchit GuptaView Answer on Stackoverflow