Rectangle 27 0

Create an XML file in Packages/User called Comments.tmPreferences with the following contents (I'm assuming the base scope of your language is source.jsx - you can find this in the .tmLanguage file):

// will remain the default comment prefix when you hit /, but when you select some text and hit Shift/ you will wrap it in {/* blahblahblah */}.

If you want to completely get rid of //, use the following instead:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>Comments</string>
    <key>scope</key>
    <string>source.jsx</string>
    <key>settings</key>
    <dict>
        <key>shellVariables</key>
        <array>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_START</string>
                <key>value</key>
                <string>{/* </string>
            </dict>
            <dict>
                <key>name</key>
                <string>TM_COMMENT_END</string>
                <key>value</key>
                <string> */}</string>
            </dict>
        </array>
    </dict>
    <key>uuid</key>
    <string>F9BFFF1F-1999-4722-B094-52E8AFD234D1</string>
</dict>
</plist>

Thanks! ... This seems good for doing {/* */} comments, but not for undoing ... Your solution leaves the curlies when you hit command + / while caret is on the line, with no selection ... typical command + / behavior removes all comment chars. But I'm not complaining, this is helpful when writing .jsx

PS: for other folks: I had to change scope to source.js instead of source.jsx for this solution to work. I know this changes comment behavior for .js files, but as front-end dev I'm dealing with mostly .jsx syntax. Thanks @MattDMo, accepting your answer now.

sublimetext - How to define comment characters for React JSX in Sublim...

sublimetext sublimetext3 reactjs react-jsx