Last active
January 16, 2018 17:34
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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