How can I expand a snippet within a snippet using YASnippet?
Asked Answered
N

1

8

At the YASnippet site I noticed the following description of yas/triggers-in-field :

If non-nil, yas/next-field-key can trigger stacked expansions, that is a snippet expansion inside another snippet expansion. Otherwise, yas/next-field-key just tries to move on to the next field.

I'm not clear how to make this happen.

I assumed that after I set: #expand-env: ((yas/triggers-in-field #t)), whenever I typed an abbrev in a field and pressed Tab it would expand, however that's not the case.

Nakada answered 4/3, 2012 at 17:2 Comment(0)
M
8

yas/triggers-in-field is a variable. Per default it is set to nil.

Its docstring says:

If non-nil, `yas/next-field-key' can trigger stacked expansions.

Otherwise, `yas/next-field-key' just tries to move on to the next field

Thus, to enable stacked expansions you have to set the variable to a non-nil value such as t. If you want this setting permanent put the following in your .emacs:

(setq yas/triggers-in-field t); Enable nested triggering of snippets

You can read about other customizable YASnippet variables

Meri answered 4/3, 2012 at 18:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.