Evaluate python string as snippet
Is it possible to evaluate/interpret a python string as a snippet?
E.g.:
------------------- SNIP -------------------
snippet "my_snip (\d+)" "create a column of names" r
`!p
def fu(n):
stri = ""
for i in range(int(n)):
stri += "+---- ${%d:my_name}\n" % i
return stri
snip.rv = fu(match.group(1))
`
endsnippet
------------------- SNAP -------------------
my_snip 3<tab> ->
+---- ${0:my_name}
+---- ${1:my_name}
+---- ${2:my_name}
But I would like the following instead:
my_snip 3<tab> ->
+---- John
+---- my_name
+---- my_name
Such that the result is the same as calling the following snippet:
------------------- SNIP -------------------
snippet "my_snip 3" "create a column of names" b
+---- {0: my_name}
+---- {1: my_name}
+---- {2: my_name}
endsnippet
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- UltiSnips Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- SirVer
- Solved:
- Last query:
- Last reply: