简体   繁体   English

WebStorm:如何将突出显示的文本放入带有前缀的 console.log

[英]WebStorm: how to put highlighted text into console.log with prefix

Since I use console.log() every day multiple times, I would like to make this a bit more efficient.由于我每天多次使用console.log() ,我想让它更有效率。

So if I have a variable:所以如果我有一个变量:

const testVariable = 0;

and I want to log this, I usually create something like this:我想记录这个,我通常会创建这样的东西:

console.log("testVariable: ", testvariable); 

which is especially helpful (compared to just using console.log(testVariable) when I am logging a lot of values).这特别有用(与我记录大量值时仅使用console.log(testVariable)相比)。 So I always know which value belongs to which variable.所以我总是知道哪个值属于哪个变量。

So my question is:所以我的问题是:

Is there an easy way in WebStorm IDE (like auto complete, code replacement, code wrapping, whatever) that I can use to highlight the variable testVariable and then do a shortcut or click somewhere and it creates this: WebStorm IDE 中是否有一种简单的方法(如自动完成、代码替换、代码包装等),我可以使用它来突出显示变量testVariable ,然后执行快捷方式或单击某处,它会创建以下内容:

console.log("testVariable: ", testvariable);

I am very thankful for any advice.我非常感谢任何建议。

You can use shortcut like this, putting the value before the dot log(.log):您可以使用这样的快捷方式,将值放在点 log(.log) 之前:

"testVariable: ", testvariable.log

After pressing tab, the result will be:按 Tab 后,结果将是:

console.log("testVariable: ", testvariable)

As referenced here:如此处所引用:

JetBrains Tip Guide JetBrains 提示指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM