Extension/custom command for comments within lines?


Hi everyone,

I’m having some trouble sorting through the multiple comment packages. I’m looking for something that will let me comment out a block of text within a line when I’m writing prose in markdown. Something like this:

Lorem ipsum dolor sit amet, <!--consectetur adipiscing elit,
sed do eiusmod tempor incididunt--> ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo

Basically I’d like to highlight text that might be within a line, or might span parts of two or more lines, and have a command that surrounds that text with comment tags.

Is there a package that will do this? Most of the comment packages (like comment) seem to comment out entire lines. If no existing package does this, can someone give me a hint on creating my own custom command that will do this?


Maybe a simple modification of this still works?! Wrap Selected Text - What's the best way?


Brilliant! Thanks @dpo, that worked perfectly.

In case someone else is interested, I just added this to my init.coffee:

wrapSelection = (selection, before, after) ->
  after ?= before
  selectedText = selection.getText()

atom.commands.add 'atom-text-editor',
  'custom:wrap-html-comment', ->
    editor = @getModel()
    editor.transact ->
      wrapSelection(selection, "<!--", "-->") for selection in editor.getSelections()