You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WebStorm 2017.3.2 Live Templates变量多函数应用及引用问题

Absolutely! Both of these requirements are totally achievable in WebStorm 2017.3.2's Live Templates—let me break down how to do each one clearly:

1. Applying Multiple Predefined Functions to a Single Input

The trick here is to create multiple template variables that all reference your original input variable, each with its own predefined function. Here's a step-by-step example:

  1. Open the Live Templates settings (go to File > Settings > Editor > Live Templates).
  2. Create a new template (click the + button, choose Live Template).
  3. In the "Template text" field, enter something like this (adjust to your use case):
    originalInput: "$FOO$",
    underscoreVersion: "$FOO_UNDERSCORE$",
    camelCaseVersion: "$FOO_CAMEL$"
    
  4. Click the Edit variables button to configure each variable:
    • For $FOO$: Leave the "Expression" field empty (this is your user-input variable), and make sure "Skip if defined" is not checked—this lets you type in the original value when using the template.
    • For $FOO_UNDERSCORE$: In the "Expression" field, enter capitalizeAndUnderscore(FOO) (note: no dollar signs around FOO here), then check "Skip if defined" so WebStorm auto-generates this value without prompting you.
    • For $FOO_CAMEL$: In the "Expression" field, enter camelCase(FOO), and also check "Skip if defined".

When you use this template, you'll only be prompted to enter a value for $FOO$, and WebStorm will automatically populate the other two variables with the transformed values.

2. Referencing Template Variables Within the Same Template

This is exactly what we did in the example above! You can reference any existing template variable in another variable's expression by using its name (without dollar signs).

If you wanted a variable like $FOO_REFERENCE$ that uses the same input as $FOO$ but with a different function, just define it in the "Edit variables" dialog with an expression like yourDesiredFunction(FOO), then use $FOO_REFERENCE$ anywhere in your template text.

You can even reference variables directly in the template text itself—like using $FOO$ multiple times in different places, each time showing the original input value.

Just keep in mind that variable references in expressions are case-sensitive, so make sure the name matches exactly what you defined for the original variable.

内容的提问来源于stack exchange,提问作者Ryder Brooks

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:52:05