Advanced snippets

Erwan Richard 8 years ago updated by Liam Cain 7 years ago 4
Please provide nested substitution, python code evalution or builtin commande evalutaion inside snippet content.

I'm trying to make a PHP class definition snippet with classname and namespace according to the current filename and the filepath. 
The problem is that I need to make 2 or 3 substitutions of TM_FILEPATH to properly get the namespace declaration.

A great functionnality would be the possibility to evaluate some python code or a set of builtin command with a kind of `substitute('foo','f','b')` syntax like in vim snippet.
I am attempting the same thing here & have the exact same issue: https://gist.github.com/3102439
I was trying to make exactly the same snippet as you do !

Finally I have made a plugin that easily insert namespace and use statements (based on ctags definition). Take a look here : https://github.com/erichard/SublimeCTagsPHP

Also, I still think that a set of builtin command would be great :-)
Allowing evaluation of python code in a snippet could open all kinds of cans of worms...but nested substitutions of a snippet would be a pretty capable feature, something like:


If there's a worry about resource usage or recursion, it would be reasonable to set an upper limit on the amount of nesting levels to allow (2 or 3, for example)
You might want to try my SMART_Snippets plugin.  It aims to solve this exact problem.  I haven't updated it in a while do to lack of interest but I'm still looking for testers (preferably people who know python and are willing to submit pull requests).