Skip to content

Instantly share code, notes, and snippets.

@thelsevier
Last active April 19, 2024 07:02
Show Gist options
  • Save thelsevier/4ba35b710b8f673473aaa64fb30c83e1 to your computer and use it in GitHub Desktop.
Save thelsevier/4ba35b710b8f673473aaa64fb30c83e1 to your computer and use it in GitHub Desktop.
VSCode console.log shortcuts snippet

HOW

Open VSCode, then:

  1. Press Ctrl/Cmd + Shift + P > Snippets: Configure user snippets
  2. Choose your programming language e.g. JavaScript
  3. Copy the section(s) you want from the snippet.json file below ✌️

Repeat for JavaScript JSX, TypeScript and TypeScript JSX

Enjoy! ❤️

... BUT WHY?

If you find yourself frequently typing console.log(), .warn() and/or .error() in order to inspect values at certain points in time during your code's execution, then you just might fancy a few shortcuts:

  • type cl[TAB] to get console.log(|) (where | is the new cursor location, right where you want it
  • cw[TAB] -> console.warn(|)
  • ce[TAB] -> console.error(|)
{
"console.log": {
"prefix": "cl",
"body": "console.log($1);",
"description": "Console Log"
},
"console.warn": {
"prefix": "cw",
"body": "console.warn($1);",
"description": "Console Warn"
},
"console.error": {
"prefix": "ce",
"body": "console.error($1);",
"description": "Console Error"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment