-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to escape $ and { characters in snippets #1670
Comments
I think this is possible @alexandrudima ? |
@wmaurer You can escape the
|
@alexandrudima Thanks a lot! In the documentation, I haven't been able to find the fact that you can escape |
@wmaurer Good point. I have pushed microsoft/vscode-docs@55ba3bb to document how to escape |
@alexandrudima Great, thanks. |
So I'm trying to create a simple string interpolation snippet as @alexandrudima suggested, but I'm getting an extra
so my output is: |
Move the first backslashes to before the $. |
@Neophius Why does it work this way? Based on what I know of escape characters I would've expected to see 1 backslash before and after the { and }. Is this a JSON thing? |
Snippets use the ${} syntax, but this is also valid Javascript/Typescript syntax for string interpolation, and this can create a conflict.
For example, I've defined a snippet as follows:
I would like initial cursor position to be where the $1 is, but due to the conflicting syntax between snippets and Typescript, I get:
... with the entire backticked string as the selection.
My suggestion would be to able to escape a $ symbol using $$, which would signal to the snippet logic that this is not a placeholder (I tried this but it doesn't work correctly - the curly braces are still missing).
The text was updated successfully, but these errors were encountered: