Search code examples
sublimetextsublimetext-snippet

Sublime text - snippet with capitalization of param first letter


I want to make snippet for Sublime Text 2 or 3 which will produce the following code:

initial - somename
with upper case - Somename

and somename is text which will be always different.

My draft for this:

<snippet>
    <content><![CDATA[
initial - ${2:somename}
with upper case - ${2:somename}
]]></content>
</snippet>

But how can I uppercase only first letter in parameter?


Solution

  • Final variant:

    <snippet>
        <content><![CDATA[
    initial - ${1:somename}
    with upper case - ${1/(.+)/\u$1/g}
    ]]></content>
    </snippet>