1

I have the following snippet

/* ----------------------------------------------------
* METHOD ${1:$$(upcase yas-text)}.
* ---------------------------------------------------- */
public function f$1($2) {
    $3
} 

My problem is that the mirror starts on METHOD, instead on public function. So the upcase characters inside the function name, that I type in METHOD will not being mirrored to the line with public function.

How could I configure the snippet to type on the line with public function, while being mirrored in the line with METHOD?

2

Using $$() indicates a field transformation, not a mirror. To get a mirror use only 1 $:

/* ----------------------------------------------------
* METHOD ${1:$(upcase yas-text)}.
* ---------------------------------------------------- */
public function f$1($2) {
    $3
}

http://joaotavora.github.io/yasnippet/snippet-development.html#sec-3-7

| improve this answer | |
  • I swear, I have read the Yasnippet documentation closely but I couldn't find any reference to inverted miirror. From which I understood, Yasnippet counts the numbers top-down. Hence my question. I'm surprised it got working. Thank you npostavs! I appreciate it! – ReneFroger Dec 17 '15 at 16:05
  • 1
    Both the documentation describing and code parsing the snippet syntax are in need of improvement. And probably the syntax itself should be improved (it's a bit hard to tell because there is no concise summary of it). – npostavs Dec 17 '15 at 16:43
  • The documentation is good, but it could be more clear on some points, I agree with you. – ReneFroger Dec 17 '15 at 20:02
  • http://capitaomorte.github.io/yasnippet/snippet-development.html#sec-3-7 is now http://joaotavora.github.io/yasnippet/snippet-development.html#sec-3-7 – Mattias Bengtsson Apr 18 '17 at 23:34
  • You're fast! :) – Mattias Bengtsson Apr 18 '17 at 23:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.