1

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?

lehtu
  • 868
  • 1
  • 12
  • 27

1 Answers1

1

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.

Michael
  • 2,631
  • 2
  • 24
  • 40