Search code examples
regexsublimetext3sublime-text-plugin

Sublime snippet - wrap selection and replace spaces


I currently have 2 snippets, one to wrap selection and another to replace spaces with underscore. How can I combine those two? First snippet:

<snippet>
    <content><![CDATA[ <%=t :${0:$TM_SELECTED_TEXT} %> ]]></content>
</snippet>

and second one:

<snippet>
    <content><![CDATA[${SELECTION/\s/_/g}]]></content>
</snippet>

I have two key bindings, and I only want to have one. Thanks


Solution

  • Problem was with TM_SELECTED_TEXT

    <snippet>
        <content><![CDATA[ <%=t :${SELECTION/\s/_/g} %> ]]></content>
    </snippet>
    

    It's working now. This snippet is useful for rails localization.