In most of the use cases on $1
I enter err
which expands to another snippet.
Then you might want to instead use
${1:err} = errors.WithMessage($1, $2))$0
That way you don't even have to type the err
in, and since the cursor will be the beginning of the field, typing TAB
will switch to the next one rather than expanding it.
I would like to temporary disable yas-triggers-in-field
for this snippet only, is there a way to do it?
Yes, add it to the expand-env
directive:
# name: errors-with-message
# key: emsg
# expand-env: ((yas-triggers-in-field nil))
# --
$1 = errors.WithMessage($1, $2))$0
Note that this requires a recent yasnippet which includes this update. It's not included in 0.11 (the latest stable release as of this writing).