Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I expand a snippet within a snippet using YASnippet?

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.

like image 306
qubital Avatar asked Mar 04 '12 17:03

qubital


1 Answers

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

like image 116
N.N. Avatar answered Oct 28 '22 23:10

N.N.