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.

Note

Hi, my name is Tania Rascia. I've turned down every offer for advertisements or sponsored posts on this website. I write free resources that have helped thousands of people successfully transition into a web development career.

My committment is to no bullshit, no sponsored posts, no ads, and no paywalls. If you enjoy my content, please consider supporting what I do.

Support my work

Newsletter

New articles on web development every two weeks.

Write a response

Your email address will not be published.

All code will be displayed literally.