Custom surround template

2019-02-06 13:09发布

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

enter image description here

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

1条回答
forever°为你锁心
2楼-- · 2019-02-06 13:27

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

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$);

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

查看更多
登录 后发表回答