lehtu
lehtu

Reputation: 907

How to lowercase first letter of Textmate snippet input?

I have shortcut for creating getter method and here is my snippet code right now:

public function get${1:PropertyName}() {
    return \$this->${1:propertyName};
}
$0

Output I'm looking for:

public function getAreaCode() {
    return $this->areaCode;
}

So the question is, how to automatically transform input's first letter into lowercase, but only on the second line?

Upvotes: 1

Views: 234

Answers (1)

Michael
Michael

Reputation: 2631

You can do a regexp match that matches the first character and modifies it like this:

public function get${1/./\u/}() {
    return \$this->${1:propertyName};
}
$0

I've used this, to also add the property and setting the scope with dropdown:

${2|private,protected,public|} \$${1};

${3|public,protected,private|} function get${1/./\u$0/}() {
    return \$this->${1:propertyName};
}
${3} function set${1/./\u$0/}(\$value) {
    \$this->${1} = \$value;
    return \$this;
}
$0

Final result

See Transformation section on Macromates for more.

Upvotes: 1

Related Questions