1

I'm new to yassnipet and it's been awesome but I hit a wall. I have the following snippet:

$1 = errors.WithMessage($1, $2))$0

In most of the use cases on $1 I enter err which expands to another snippet.

I would like to temporary disable yas-triggers-in-field for this snippet only, is there a way to do it?

2

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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