Quick console logs in VSCode
1 min readDec 27, 2019
If, like me, you use a lot of console logs while coding, then the quicker you can write them the better!
This is a useful little variation to the existing code snippet which adds multiple cursors for logging a comment and variable simultaneously!
In VSCode go to: Code/Preferences/UserSnippets
For javascript files search:
- javascript.json
- javascriptreact.json
For typescript files search:
- typescript.json
- typescriptreact.json
Add the following snippet to each file:
"Print to console": {
"prefix": "cl",
"body": [
"console.log('$1 is ', $1)"
],
"description": "Log output to console"
}
Now, to add a new console log simply type cl
and hit the Enter
key!
Because there are two $1
variables, as you type there will be two cursors. One in the ‘comment’, and one outside for the variable to log!