does webstorm have some shortcut for console.log o

2019-03-11 13:41发布

Just tired of typing console.log again and again, and do not find a way like 'Sysout + Control + Space' in Eclipse will create System.out.println().

4条回答
冷血范
2楼-- · 2019-03-11 14:09

I made my own template that seems to work. It may be useful for somebody.

Abbreviation: ll

Template text:

console.log('$NAME$ ', $VALUE$);
    $END$

Variables: (just select the given field values by clicking drop down box)

  1. NAME - jsDefineParameter()
  2. VALUE - jsSuggestVariableName
查看更多
孤傲高冷的网名
3楼-- · 2019-03-11 14:10

There's a predefined Postfix template that allows you to type .log after a JavaScript expression or string and hit Tab to transform it to console.log().

You can also create a Live template (see Preferences | Editor | Live templates) that would expand into a code snippet once you type the selected abbreviation and hit Tab.

Update: there's now also a plugin that allows you to add console.log with a shortcut: https://plugins.jetbrains.com/plugin/10986-console-log

查看更多
爷的心禁止访问
4楼-- · 2019-03-11 14:18

Yes it does,

<anything>.log and press Tab key. This will result in console.log(<anything>);

ie,

<anything>.log + Tab => console.log(<anything>);


eg1: variable

let my_var = 'Hello, World!';
my_var.log + Tab => console.log(my_var);

eg2: string

'hello'.log + Tab => console.log('hello');

eg3: string and variable

'hello', my_var.log + Tab => console.log('hello', my_var);
查看更多
Luminary・发光体
5楼-- · 2019-03-11 14:26

I made a custom template. This can help you.

Abbreviation: clog

Template code:

console.log("\n\n--------------------------------");
console.log($END$);
console.log("--------------------------------\n\n");
查看更多
登录 后发表回答