VS Code: Custom Snippets

2 minute read Published:

My custom snippets for VS Code. TODO, NOTE

I love VS Code, I was previously a vim user. I loved it too, mostly for the nostalgic console feelings. Fatih Arslan wrote a very good Go plugin called vim-go which made it even better. I’m getting tired of messing with configuration and setting up new machines, so now I’m 100% VS Code. And it’s pretty glorious. I’ll write up my extensions and setup in another post.

This post is about snippets, you can set custom code snippets for different languages. So since I mostly write Go, and I like to sign my TODOs, I wanted a quick way to fill it in.

Example go.json

This example shows my current configuration for TODO comment snippets.

	"TODO Signed": {
		"prefix": "td",
		"body": [
			"// TODO:(rob loranger) "
		"description": "Start a single line todo comment with name"
	"TODO Block Signed": {
		"prefix": "ttd",
		"body": [
			"/*\n\tTODO:(rob loranger)\n\t$0\n*/"
		"description": "Start block todo comment with name"

So typing td then hitting tab expands into:

// TODO:(rob loranger) 

Followed by a space so I can just start typing my comment. You can use place holders in the snippet body as well. $0 for final cursor position. When I tried using actual new lines or tabs it broke the snippet.

You can define your own snippets for specific languages. To open up a snippet file for editing, open User Snippets under File > Preferences (Code > Preferences on Mac) and select the language for which the snippets should appear.

Taken from this page, check it out for more detailed information.