wrap/surround 选择的 WebStorm 快捷方式?

WebStorm shortcut to wrap/surround selection?

在编码和制作模板时,我经常需要将文本的特定部分换行。在WebStorm中是否有任何快捷方式来包装当前选择?

例如:

camel
//to
"camel"

或:

var x = 8;

//to
function(){
var x = 8;
}

我尝试使用 Ctrl+Alt+J 的 Using Surround Templates 但我得到了答案 "No surround templates defined in this context"。

我在 WebStorm 2016.2.4 中使用

camel
//to
"camel"

这样的环境可以在设置中启用(如果你没有启用的话):

Settings/Preferences | Editor | General | Smart Keys --> Surround selection on typing quote or brace


var x = 8;

//to
function(){
var x = 8;
}

Live Template 是正确的选择。确保您使用 $SELECTION$ 来表示选定的文本——它是 key hint for IDE——它表明这是 "Surround With" 的一种实时模板。

这包含在:

因此您的实时模板应如下所示:

function(){
    $SELECTION$
}