does webstorm have some shortcut for console.log or console.info

前端 未结 9 1948
野的像风
野的像风 2021-02-01 11:45

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().

相关标签:
9条回答
  • 2021-02-01 12:10

    I made a custom template. This can help you.

    Abbreviation: clog

    Template code:

    console.log("\n\n--------------------------------");
    console.log($END$);
    console.log("--------------------------------\n\n");
    
    0 讨论(0)
  • 2021-02-01 12:11

    Simplest live template text:

    console.log($END$);
    
    0 讨论(0)
  • 2021-02-01 12:14

    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);
    
    0 讨论(0)
  • 2021-02-01 12:24

    [UPDATE 2020]

    Typing log + Enter autocompletes to console.log()

    0 讨论(0)
  • 2021-02-01 12:28

    Maybe it is a recent addition but you can write log and hit tab and console.log() will appear with the caret in between the braces.

    The answer from Ekaterina Prigara (https://stackoverflow.com/a/32975087/5653914) was very useful to me but if you want to log a string like "Test" this method is quicker.

    0 讨论(0)
  • 2021-02-01 12:31

    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
    0 讨论(0)
提交回复
热议问题