Console Log Snippet

November 19, 2024

Well, console.log is already short enough. In VS Code, you can simply type log to expand it into console.log.

Can we make it even faster, though? Sure, by typing asd.

Here's an example of a VS Code snippet. Using the default VS Code template, we just tweak it slightly:

{
	// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and 
	// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
	// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
	// same ids are connected.
	// Example:
	"Print to console": {
		"prefix": "asd",
		"body": [
			"console.log($1)",
		],
		"description": "Log output to console"
	}
}

Here, I removed the extra newline, the quotes, and the semicolon. Typically, we log a variable rather than a string, and we naturally hit a new line before logging. As for the semicolon, it just feels neater with fewer characters on the screen, I guess.

Now, you can trigger the console.log snippet without moving your hand much—assuming your hand is naturally placed on ASD, the typical gaming finger position.

Comments

Thank You

for your visit