Insert comment at end of line


I’ve recently come over to Atom from Brackets and have been trying both Atom and Sublime Text 3. I’m sure this has been asked before and maybe I’m not using the correct search term, but how do you insert a comment at the END of a line?

I’m used to cmd + alt + / (Mac user) and this works in both Brackets and ST. Is it a key mapping issue or something else?


Are you asking about a feature where you can press a keybinding and, no matter where in the line the cursor is, it jumps to the end and adds comment tags?

I haven’t heard of or seen such a thing (and searching the keybindings doesn’t bring anything up), but it wouldn’t be hard to define a command in that does exactly this.


Apologies if I wasn’t clear but I’m happy to place the cursor at the end of the line myself. I’m looking to add the comment at the end of the line after I place the cursor and invoke the keyboard shortcut. I also want it to be smart, so in PHP I get this //
HTML <!-- -->
CSS /* */

I don’t want to comment out a whole line, just add a comment at the end of say, a closing </div> <!-- like this -->


For that, you could make a set of snippets with the same prefix in different scopes.


Thanks. Can snippets be triggered with key combinations (cmd+alt+/) rather than typing the prefix and then hitting enter/tab? You have provided a working solution but I’m looking for a quicker one if possible.


It’s possible to make a keybinding that has Atom enter some text and then invoke snippets:expand, of course. If you go that way, I see no reason to not also have that command jump the cursor to the end of the line. That would be fastest.


Thanks again. Actually, as commenting is important to my workflow and the Atom setup was less than intuitive, I’ve gone back to Sublime for my main work.
I’m still using Atom for basic HTML because of the browser-plus package, but wish it was faster! Even on a well-spec’d machine with an SSD drive it loads pretty slowly.