自定义环绕模板

自定义环绕模板

问题描述:

如何定义我自己的自定义环绕模板,我可以使用它来包装选择的javascript代码,然后重新格式化。

How can I define my own custom surround template that I can use to wrap around a selection of javascript code followed by reformat.

我用过 Alt + Cmd + T 打开此选项面板。

I've used Alt + Cmd + T to bring up this option panel.

转到设置/实时模板,创建一个新的Live模板,指定缩写,描述和上下文,检查根据代码样式重新格式化

Go to Settings/Live Templates, create a new Live template, specify abbreviation, description and contexts, check Reformat according to code style.

现在重要的部分。 Live模板内容必须包含 $ SELECTION $ 变量才能适用于Surround with action。例如:

And now the important part. The Live template content must contain $SELECTION$ variable for it to be applicable for Surround with action. For instance:

console.log($SELECTION$);

保存模板后,下次使用时,应在弹出列表中看到它em> Surround With 动作。

After you save the template you should see it in the pop-up list next time you use the Surround With action.