Reputation: 121
I'm trying to create a simple snippet:
'.source.c':
'prinf':
'prefix': 'souf'
'body': 'printf("%$1\n");'
The problem is: it actually makes the newline instead of writing \n
:
printf("%
");
I want: printf("%\n");
I've also tried \\n
in the body of the snippet, but it only writes n
: printf("%n");
Do you know how to? Thanks
Upvotes: 1
Views: 218
Reputation: 4834
Late to the show, but per their docs, you use a triple quotation syntax """
.
Their example is:
'.source.js':
'if, else if, else':
'prefix': 'ieie'
'body': """
if (${1:true}) {
$2
} else if (${3:false}) {
$4
} else {
$5
}
"""
It's coffee script or something. But I just wrote a .then().catch()
using this method and it worked great.
Upvotes: 0
Reputation: 33159
You need to use four backslashes.
'body': 'printf("%$1\\\\n");'
From what I can tell, the first pair are used when setting the snippet (c.f. \n
), the second pair are used when using the snippet (c.f. \\$1
).
Upvotes: 1