1

I would like to create a yasnippet snippet as follow: pressing weather I would like that would be inserted the following text current weather = with the cursor after the = (this can be done with current weather = $1). I would so like that a context menu with some suggestion will appear, like sunny, rainy, and so on.

How can I do this? Have I got to use in some ways autocomplete or company? Thank you.

2

One way to do this is with yas-choose-value:

# -*- mode: snippet -*-
# key: weather
# --
current weather = ${1:$$(yas-choose-value '("sunny" "rainy"))}

Please read through the writing snippets section of the documentation because it answers many of your recently asked questions.

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.