This is for visual studio.

As suggested by Adrian Smith and others: If you want to bind a keyboard shortcut to create a console log statement, you can do the following:

  1. File > Preferences > Keyboard Shortcuts
  2. Below the search bar you’ll see a message “For advanced customizations open and edit keybindings.json”, click on it
  3. Add this to the JSON settings:
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log('${TM_SELECTED_TEXT}$1')$2;"
}
}

Pressing CTRL+SHIFT+L will output the console snippet. Also, if you already have text selected it will be put inside the log statement.


If you rather want intellisene/autocomplete:

Go to Preferences -> User Snippets -> Choose Typescript (or whatever language you want). A  json  file should open. You can add code snippets there.

There is already a snippet for  console.log  commented out:

"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}

You have to do this for every language you want to use the snippet … is kinda bothering.


Also, you should set  "editor.snippetSuggestions": "top" , so your snippets appear above intellisense. Thanks @Chris!

You can find snippet suggestions in Preferences -> Text Editor -> Suggestions

Source: https://stackoverflow.com/questions/40177331/what-is-the-shortcut-in-visual-studio-code-for-console-log