vim snipmate - use a variable multiple times in a snippet
Asked Answered
B

1

8

sometimes I need to use a variable multiple times in a snippet. For instance, when I need to set a key-value list:

${1}_key: ${1}_value

I hope the cursor can stop at the first ${1} when I trigger snipmate in this case. When I input something like foo at the first ${1}, it can become

foo_key: foo_value

Thus, I need to input foo only once. How can I achieve this?

Bathurst answered 19/9, 2013 at 9:56 Comment(0)
B
13

It's easy:

${1:}_key: $1_value
Bathurst answered 19/9, 2013 at 10:2 Comment(2)
Why is the colon required at ${1:}?Upgrowth
Frankly, I don't know. (Maybe I knew it before, but I can't remember it now) But I want to say Hi to you. I saw your ID before. Thanks for letting the world know the shitty things happening in China :)Bathurst

© 2022 - 2024 — McMap. All rights reserved.