Skip to content

Instantly share code, notes, and snippets.

@code-vagabond
Forked from Zequez/init.coffee
Created December 27, 2016 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-vagabond/7eeaa298e14ff69a7ab4ebd22a5bc591 to your computer and use it in GitHub Desktop.
Save code-vagabond/7eeaa298e14ff69a7ab4ebd22a5bc591 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
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