1

I have a ultisnip that looks like this:

snippet "[A-Z]+-[0-9]+" "Jira Link" r
[`!p snip.rv = match.group(0)`](https://ellation.atlassian.net/browse/`!p snip.rv = match.group(0)`)
endsnippet

This works fine. But I was hoping there might be a way to do this without duplicating the two python blocks?

1

Sure! Instead of interleaving actual text with Python code, build the whole string with Python:

snippet "[A-Z]+-[0-9]+" "Jira Link" r
`!p identifier = match.group(0)
snip.rv = "".join([
    "[", identifier, "]"
    "(https://ellation.atlassian.net/browse/", identifier, ")"])`
endsnippet

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.