57fl_q
Last Updated: February 25, 2016
·
1.309K
· darthapo
49d66f6f58c4c148eabdd7b2e393d52d

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'
Say Thanks
Respond