Skip to content

Instantly share code, notes, and snippets.

@pitkane
Forked from Zequez/init.coffee
Last active January 27, 2016 12:33
Show Gist options
  • Save pitkane/78daba268083921a738c to your computer and use it in GitHub Desktop.
Save pitkane/78daba268083921a738c to your computer and use it in GitHub Desktop.
Comment out JSX code on Atom
# If you worked with React and JSX you probably noticed that you can't use JS comments when inside JSX sections
# Add this to your Atom init script
# Then add 'ctrl-cmd-/': 'comment-jsx' to your keymap.cson
# Then when you are on a JS/JSX file, just press cmd+ctrl+/ to use JSX-style comments that work with JSX elements
# Is not the most efficient way, but it's the cleanest and reliable one
# FORK UPDATE 27.1.2016:
# Overwriting "Toggle Comments" function:
# '.workspace .editor:not(.mini)':
# 'cmd-/': 'comment-jsx'
atom.commands.add 'atom-workspace', 'comment-jsx', ->
atom.config.set('editor.commentStart', '{/*', {scopeSelector: '.source.js.jsx'})
atom.config.set('editor.commentEnd', '*/}', {scopeSelector: '.source.js.jsx'})
for selection in atom.workspace.getActiveTextEditor().selections
selection.toggleLineComments()
atom.config.unset('editor.commentStart', {scopeSelector: '.source.js.jsx'})
atom.config.unset('editor.commentEnd', {scopeSelector: '.source.js.jsx'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment