Skip to content

Instantly share code, notes, and snippets.

@joeycozza
Last active January 16, 2018 17:34
Show Gist options
  • Save joeycozza/ef6b08b84c61bd34ea7c199fc61273fc to your computer and use it in GitHub Desktop.
Save joeycozza/ef6b08b84c61bd34ea7c199fc61273fc to your computer and use it in GitHub Desktop.
An Ultisnips snippet that will take a visual selection of string concatenation, and turn it into ES6 templatized string.
snippet str "ES6 String Templatize a string concat visual selection"
\``!p
split = snip.v.text.split("+")
finalStr = ""
for x in split:
x = x.strip()
if x[0] == "'" or x[0] == "\"":
x = x.strip("\"'")
finalStr += x
else:
finalStr += "${" + x + "}"
snip.rv = finalStr
`\`
endsnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment