Last Updated: February 25, 2016
·
2.083K
· darthapo

Customize ATOM to comment React JSX blocks

I'll admit this isn't the most polished... But here's a command I added to Atom for commenting out blocks in React JSX files:

init.coffee:

atom.workspaceView.command 'my:comment-jsx', ->
  editor= atom.workspaceView.getActiveView().getEditor()
  return unless editor.selections.length and editor.cursors.length
  cursor= editor.cursors[0]
  return unless 'source.js.jsx' in cursor.getScopes()
  text= editor.selections[0].getText()
  editor.insertText( "{/*#{ text }*/}" )

And for a helpful shortcut:

keymap.cson:

'.editor':
  'alt-cmd-/': 'my:comment-jsx'