Insert comment at end of line


#1

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?


#2

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 init.coffee that does exactly this.


#3

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


#4

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


#5

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.


#6

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.


#7

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.