Add comment and insertion point


When on a blank line in an HTML file, typing command-/ inserts a comment <!-- --> but puts the insertion point after the closing comment tag, instead of inside the tags where the comment should go. I always need to click to move the insertion point.

Is there any way to fix?


The reason it does that is because you’re supposed to select a section of code first, and then the Cmd-/ key mapping will wrap that section in comment tags.

I don’t think it’s meant to just create the tags for you to fill in the comment afterwards. It’s not an auto-complete feature, is what I’m saying.
But I’m sure there are packages that do it, maybe incl. autocomplete-plus?


Well, I (and I’m sure many devs) do both: “comment out” something and add a comment to myself and others explaining something, or even to keep track of what’s what on a complex page.


I agree. I’m just wondering if this second scenario is covered by a different key mapping, maybe provided by some other package.


It makes sense from a user’s perspective to DWIM: If nothing is selected, then insert a comment and allow me to type something into it. If something is selected, then wrap that in a comment and then allow me to add to the comment.

Like parens: If nothing is selected and I type an open paren, I get a paren pair and type inside it. If something is selected and I type an open paren, I get the selection wrapped in a paren pair and I can cursor-left or cursor-right to disable the selection, then type.


This is also exactly how most code editors work, AFAIK.


I haven’t tried snippets yet but don’t they support what you want?


Perhaps. But IMO the behavior of the stock app is incorrect. I was hoping it could be reviewed.


Please open an issue on Atom Core, if there isn’t one already. I suspect this is a limitation in the current implementation of the comment selection command.


added to issues list


For the record:


I am revisiting this because the previous “solution” was not to use Emmet.

But I like using Emmet, it’s a big timesaver.

I was able to edit my keymap so that, for regular comments cmd-/ is handled by Atom Core and works as expected.

I am still trying to figure out a way to key the stock shortcut of -- tab to create <!-- (cursor)--> for me. Currently, Emmet intercepts this and expands it to <--></-->. Duh.

So I am trying to create a snippet or keystroke that would be fired first before Emmet’s “expand with tab” shortcut, and create the html comment as desired above.

Any suggestions?