Tania Rascia

Skip Navigation
How to Create a Snippet in Visual Studio Code

How to Create a Snippet in Visual Studio Code

 /  Leave a response

Here’s how you make a custom, global snippet in VSCode.

Press COMMAND + SHIFT + P to open the command palette.

Find “Preferences: Configure User Snippets”.

Click “New Global snippets file”. This will open up a file with a .code-snippets extension in ~/Library/Application Support/Code/User/snippets/filename.code-snippets.

I made one that will allow me to type perr + TAB to print forced PHP errors.

PHPErrors.code-snippets
{
	"Show PHP Errors": {
		"scope": "php",
		"prefix": "perr",
		"body": [
			"ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);"
		],
		"description": "Show PHP Errors"
	}
}

And that’s all.

Newsletter

Get updated when I create new content.
Unsubscribe whenever. Never any spam.

Note

I'm Tania. I turn down every ad, affiliate, and sponsor request I get. I write free resources that help thousands of people successfully become devs. If you enjoy my content, please consider supporting what I do.

Support my work

Write a response

Your email address will not be published. Required fields are marked *

All code will be displayed literally.