+3

Advanced snippets

Erwan Richard 12 år siden opdateret af Liam Cain 12 år siden 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.
+2
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 :-)
+1
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:

${${var_name/regex/format_string/}/regex/format_string}

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).

Kundesupport af UserEcho