This doesn't need any extra extension, just use the default VSCode editor.
Go to Command Palette (⌘ ⇧ + P) and open Preferences: Open Keyboard Shortcuts (JSON)
menu.
Inside the JSON file, add this object:
keybindings.json
{
"key": "ctrl+alt+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log({ ${1:${CLIPBOARD}} }, '${TM_FILENAME} line ${TM_LINE_NUMBER}')"
}
}
Note: This is for macOS. You can change the keybinding to which you prefer.
You can also customize the snippet format to your liking. VSCode has a bunch of magic variables that you can use!
Usage
- Copy the text that you want to log. Notice the usage of
{${1:${CLIPBOARD}}
) - Press
Ctrl + Alt + L
to insert the console log statement.