LiveTemplate - file name without extension

I want to create a live template for test files that have name like "SomeComponent.spec.jsx", where the component being tested is automatically imported, e.g.


import './$FILENAME$.jsx';


The filenameWithoutExtension function doesn't work here as it only strips the last extension, leaving me with "SomeComponent.spec". I tried a few combinations of other functions but couldn't find anything that worked. The groovy one looked promising until I ran into the same problem as this: 


Is there a way of getting the filename without any extension in this case with the existing (working!) webstorm live template functions?


I did this using regularExpression:

regularExpression(fileNameWithoutExtension(), ".spec$", "")

Hi there,

Have you thought about calling that "filenameWithoutExtension function" again? Something like this (or whatever the right syntax is):


Ooo, nice idea, hadn't thought of that! Sadly it doesn't seem to work - I still get "SomeComponent.spec" as the value - I suspect that fileNameWithoutExtension ignores any arguments I give it and just returns the value based off the current filename, so nesting it has no effect


I had the same problem. I decided to use just a simple variable and use the autocomplete function to suggest the filename for me.


You can use


Please sign in to leave a comment.