Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does webstorm have some shortcut for console.log or console.info?

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

like image 429
Chopper Lee Avatar asked Oct 06 '15 02:10

Chopper Lee


People also ask

How do I create a shortcut in WebStorm?

Add a mouse shortcutOn the Keymap page of the Settings/Preferences dialog Ctrl+Alt+S , right-click an action and select Add Mouse Shortcut. In the Mouse Shortcut dialog, move the mouse pointer to the central area and click or scroll as necessary. Click OK to save the shortcut.

How do I console log?

Steps to Open the Console Log in Google Chrome With the Chrome browser open, right-click anywhere in the browser window and select Inspect from the pop-up menu. By default, the Inspect will open the "Elements" tab in the Developer Tools. Click on the "Console" tab which is to the right of "Elements".


2 Answers

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

like image 58
Ekaterina Prigara Avatar answered Oct 23 '22 04:10

Ekaterina Prigara


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); 
like image 40
Saahithyan Vigneswaran Avatar answered Oct 23 '22 05:10

Saahithyan Vigneswaran