Commenting out code blocks in Atom
Atom EditorAtom 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:
- Comment package for atom (https://atom.io/packages/comment)
- Block-comment-lines https://atom.io/packages/block-comment-lines
- Sublime Block Comments
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 :
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
- comment - https://atom.io/packages/comment
- 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:
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
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