Last Updated: February 25, 2016
·
2.5K
· 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'

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

A React app still loads third-party scripts outside the component tree. Tag managers, analytics, and payment fields can read the DOM those components render.

Security insights from Cside