Skip to content

Instantly share code, notes, and snippets.

@ruv
ruv / atom-editor-user-command.coffee
Created Mar 21, 2019
Wrap selected text with common formatting tags
View atom-editor-user-command.coffee
wrap_selection_with = ( tag ) ->
e = atom.workspace.getActiveTextEditor()
m = e.markBufferPosition( e.getCursorBufferPosition() )
s = e.getSelectedBufferRange()
e.setCursorBufferPosition( s.end )
e.insertText('</' + tag + '>')
e.setCursorBufferPosition( s.start )
e.insertText('<' + tag + '>')
e.setCursorBufferPosition( m.getHeadBufferPosition() )
You can’t perform that action at this time.