Is it possible to have a history for the value of a yasnippet field? When I expand a second time a snippet like \begin{${1:environment}} I would like to get as suggestion the value I've used for $1 in the last expansion.

1 Answer 1


I've found a solution with a pseudo-field in which I save the previous value and jump to the next. It feels ugly and I hope someone can give a better answer.

# -*- mode: snippet -*-
# name: Environment
# key: env
# --
\begin{${1:`(or (and (boundp 'last-snippet-environment) last-snippet-environment) "environment")`}}
  $0${2:$$((lambda ()
    (set (make-local-variable 'last-snippet-environment) (yas-field-value 1))

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.