質問

LiveTemplates in Webstorm and all IDEA family products one of those nice features that bring pure awesomeness to your coding. So for the snippet like this:

stylus = require "stylus"

I can set abbreviation (for example rqr) and set the template text like this:

require "$END$"

tell Webstrom that this is applicable for coffeescript and voila, I have to type only that:

stylus = rqr[TAB]

But, I thought: "can I go even further with this?" Can I somehow tell Webstorm to read the word that I typed right before the abbreviation (in this case it's stylus), and Webstorm would automagically put it between quotes and finish on the next line? Wouldn't be that cool? So you would type: express = rqr[TAB] and it would finish that for you, expanding it into:

express = require "express" 
役に立ちましたか?

解決

Wow, wow, wow! I actually found a better way to do that...

if I keep the same abbreviation and change template text into:

 $module$ = require "$module$" 
 $END$

it does want I wanted, but in the way cooler way!

So you can use your own variables in a template as long as you don't call them $END$ or $SELECTION$

Awesome!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top