I want to do something like this, not sure how to do it?
snippet a
${1: 'a'}
endsnippet
snippet b
" I want to expand snippet a here?
${1: 'b'}
endsnippet
Not sure what are you asking for.
@andreyorst let me try again
With the above example (slightly modified):
snippet a
${1: 'I am snippet A'}
endsnippet
snippet b
a "<-- I want to expand snippet a here when the b snippet is expanded
${1: 'I am snippet B'}
endsnippet
When I expand b I want also that the a snippet inside of it to be also expanded automatically. So the output of expanding b in this example will look like this:
'I am snippet A' <-- this is the result of expanding snippet a inside snippet b
'I am snippet B'
Does this make sense now?
I've understood. Sadly, I don't know if it is possible or not. I understand the approach not to copy snippet inside another snippet, but I don't think that it was meant to work like so. Snippets are small piece of code. Even if they are _interactive_ piece of code, I don't think that such complex mechanics should be involved. It should be complete piece of code. I understand that you may want to say, sometimes expand a, and sometimes expand b, wich contains a's body, but it seems to me that theese two are two separate snippets.
Maybe you need to look into Documentation#UltiSnips-pre-expand-actions and postexpand too. Maybe you need to use UltiSnips#Anon somehow.
Thanks @andreyorst, will have a look at the pre-expand-actions then.
There is an approach described in https://github.com/SirVer/ultisnips/blob/master/doc/examples/snippets-aliasing/README.md, which works in many cases.
Otherwise this would be a cool feature, but very complex to implement in the current design. Since this is unlikely to happen, I will close this as wontfix.
Most helpful comment
I've understood. Sadly, I don't know if it is possible or not. I understand the approach not to copy snippet inside another snippet, but I don't think that it was meant to work like so. Snippets are small piece of code. Even if they are _interactive_ piece of code, I don't think that such complex mechanics should be involved. It should be complete piece of code. I understand that you may want to say, sometimes expand
a, and sometimes expandb, wich containsa's body, but it seems to me that theese two are two separate snippets.Maybe you need to look into Documentation#UltiSnips-pre-expand-actions and postexpand too. Maybe you need to use
UltiSnips#Anonsomehow.