Is it possible to add snippets with fixed width fields?

Asked by Jorge

I have the following snippet definition to add a variable in C:

snippet av
${1:type} ${2:var_name }; ${3:/**< ${4:explanation} */}${0}
endsnippet

I would like to know if is possible to modify the snippet in such a way that the width of
each field if fixed.
What happens right now is something like this

int myvar1;
long int myvar2;

so the column where the variable name is depends on how big the variable type is.
I would like to know if there is a way of making the variable name start always in the same column.

Thanks.

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:
Revision history for this message
Best SirVer (sirver) said :
#1

you need to insert python code blocks of variable width between the tabstops, e.g.

snippet fw
${1:type}`!p snip.rv = (20-len(t[1]))*" "`${2:var_name}

endsnippet

Revision history for this message
Jorge (skeept) said :
#2

This is exactly what I wanted.

Thanks.

Revision history for this message
Jorge (skeept) said :
#3

Thanks SirVer, that solved my question.