3

Let's say that I have the following snippet in Emacs:

# -*- mode: snippet -*-
# name: frac
# key: frac
# --
\frac{${1:numerator}}{${2:denominator}}$0

My problem is that when I write a snippet inside this snippet and press tab then the snippet is not expanding but the cursor is moving to the next placeholder.

How can I make it to first expand the snippet and then, with the next tab ro move, to the next placeholder?

2
  • Could you perhaps show also the second snippet inside the first?
    – Drew
    Mar 5, 2017 at 2:18
  • @Drew There is not one specifically. Also the one I wrote is just an example. Every time I write a snippet and I want to nest one more then the tab moves the cursor without expanding first the second snippet.
    – Adam
    Mar 5, 2017 at 13:00

1 Answer 1

4

From This SO answer, we see that:

yas-triggers-in-field is a variable defined in yasnippet.el.

Its value is t

Original value was nil

Documentation:

If non-nil, allow stacked expansions (snippets inside snippets).

Otherwise yas-next-field-or-maybe-expand just moves on to the next field

You can customize this variable.

So the solution to allow nested templates is:

(setq yas-triggers-in-field t)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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