Sublime Forum

$TM_FILENAME without extension; $TM_FILEPATH w/out filename?

#1

Hey All,

I’ve got a snippet I’m trying to write that should insert these lines into the current file:

%let out_folder = <<full path of the directory that the current file lives in>> ;

ods html path = "&out_folder" (URL=NONE)
         body   = "<<current file name minus extension>>.html" 

So if I’m editing a file called \bibbity\bobbity\boo.sas I want to see

%let out_folder = \\bibbity\bobbity\ ;

ods html path = "&out_folder" (URL=NONE)
         body   = "boo.html" 

Judging from the list of snippet env vars on this page, there aren’t any env vars that will suit these needs.

Is that right, or are there other vars not listed?

If it is right, can anyone tell me (or point me to docs explaining) how I can manipulate the values of these vars before they get inserted?

It’d also be lovely to get native windows backslashes as the path seperator character if that’s possible, though I can live w/the forwardslashes if need be.

Many thanks!

-Roy

0 Likes

#2

Finally solved these, after much trial-and-error. The answer to how to manipulate the values is on the very page that I linked to in my original post (duh, Roy)–you use regexes.

Current filename w/out extension:

${TM_FILENAME/(.*).](.*)/$1/g}

Current path w/out filename:

${TM_FILEPATH/(.*\/)(.*)/$1/g}

I have the vague idea from this thread that it should also be possible to change those forward-slashes to backs w/a single gnarly-ass regex, but my regex-fu is not nearly that strong.

0 Likes

#3

I want to Remove extension like: fileName.blade.php as fileName without extension. How can I do that?

0 Likes

#4

I got the ans:
${1:${TM_FILENAME/(.+)…+…+/$1/}}

0 Likes