Sublime Forum

Single quotes in snippets

#1

class InsertDateWithSnippetCommand(sublimeplugin.TextCommand): def run(self, view, args): dateAsStr = datetime.datetime.today().strftime("%x") snippet = "Today's Date: $1 abc $2 abc ${3:%s}" % dateAsStr view.runCommand("insertInlineSnippet '%s'" % snippet)

This will insert only Today into the buffer. Is this intended? How do we escape characters in snippets?

0 Likes

#2

Ok. Just do \’.

0 Likes

#3

You can also let runCommand do the escaping for you:

view.runCommand("insertInlineSnippet", [snippet])
0 Likes