How do I clear selection with custom command in


I’m trying to make a macro to insert '* ’ to beginning of each line in selection. It looks like this:

atom.commands.add 'atom-text-editor', 'custom:split-home', ->
 editor = atom.workspace.getActiveTextEditor()

afterwards I need to clear selection and instert text '* '. Something like that:

editor.clear() # get error because it's not an editor method but a `selection` object method
editor.insertText("* ")    

And I can’t get around it with atom.commands.dispatch() because there is no separate command to clear selection.
So, how do I access this method properly?


Tried editor.insertText("* ") and it added symbols, not replaced selection. But I’m still intrested in how to access extended classed properly.


editor.getLastSelection().clear() will eliminate the most recent selection.