Escaping a newline in a snippet


#1

Hello,

I’m trying to add a snippet for a simple golang printf statement:

'body': 'fmt.Printf("$1  %+v \n", ${1:e})'

Which is to produce something like:

fmt.Printf("somevar %+v \n", somevar)

However I can’t escape the newline so that it prints as “\n”. I have tried using “/” and “” but no luck.

So how do you escape “\n” in a snippet?


#2

I found the solution…

'body': 'fmt.Printf("$1  %+v \\\\n", ${1:e})'

That’s four backslashes in there. That means its really really really escaped… Not just a little bit escaped :smile: