Comment selected text, not entire line


CMD-/ nicely comments an entire line. It also comments multiple lines if I select them. But if I selected specific text within a single line, the entire line still becomes the comment. Only my selection should become the comment.

Perhaps some languages do not permit this, but I’m primarily concerned with HTML, CSS, and JS

This behavior is present in Sublime Text if you need an example.

I apologize if this has already been requested. I did a search and did not see it.


I have the same problem here.
If you use php in atom it is really a problem than the comment is not working because the commentsyntax is outside the php brackets.


Last I checked, there isn’t support in the API for commenting out just the selection in languages that support it. Check out in atom/atom for what is there.


I’m new here, how do I upvote this?


Just made the switch to Atom from Sublime Text and whilst I love the editor this is one thing I sorely miss. Has anyone made any progress on this issue?


Actually I got around this by changing my keymap to have block-comment handle ‘cmd-/’ as follows:

'atom-workspace atom-text-editor:not([mini])':
  'cmd-/': 'block-comment:toggle'

Hope this helps someone.


Could you walk me through the steps on how you altered your Atom?

I thought I found the right place and put in what you wrote but so far I see zero change. I was hoping your fix would make Atom’s comment function work like Sublime’s comment function.


post deleted , found solution


Your solution is great for HTML.
Same thing wityhn PHP tags (/SELECTION/) ?