Sublime Forum

Is there any way to use $project_base_name in a snippet?

#1

Hi!
I’m a recent convert from notepad++ w/ FlashDevelop and I’m extremely impressed with ST2.

The one thing I miss, however, is the ability to use certain pieces of project info inside a snippet.

For example, in FD4 I can do:
$(ProjectName)Globals.Log("$(CurFilenameNoExt)", “$(MbrName)”, “$(EntryPoint)”, 3);

Which spits out something like
MoveAnythingGlobals.Log(“DragUnit”, “configUI()”, “entrypointgoes here”, 3);

I realise that there’s a way to do file name, but I’d ideally like to drop the extension, as well as fold in $project_base_name (from the build system.

Membernames are obviously going to vary wildly on the implementation due to the variety of supported languages; I don’t mind that at all and can cope. But being able to inject project name and extensionless filename would make my transition over sooooooo much easier.

Any suggestions?

0 Likes

#2

After a bit of tinkering I finally realised I could just implement it thanks to having a pretty predictable file path. Ended up with:

<snippet> <content><![CDATA[ ${TM_FILEPATH/^\/E\/TSW\/GitHub\/(\w+).*/\1/g}Globals.Log("${TM_FILENAME/(.*)\.as/\1/g}", "${1:MemberName}", "${2:Message}", ${3:3}); ]]></content> <tabTrigger>loge</tabTrigger> <scope>source.actionscript</scope> </snippet>

0 Likes