-
Notifications
You must be signed in to change notification settings - Fork 28.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
Support snippet variables #4956
Comments
Any chance this is going to be considered? :) |
@martinring I agree that our documentation does not explicitly mention that variables are not supported, but AFAIK they were never implemented. So this issue is a feature request. |
@alexandrudima ok thank you for the clarification. surrounding snippets are quite a common feature of editors. visual studio supports them as does textmate for example. I might look into adding that. |
I'll add in my vote. Being able to highlight text, run a snippet and have that highlighted text replace $TM_SELECTED_TEXT in the snippet is super useful. (Both Textmate and Sublime support this) |
desired variables: selected text, filename, date |
We now support |
I would like to have a TM_FILENAME w/o the extension so i could, for exemple, create a snippet for auto naming a class base on the filename. |
+1 for getting the filename without extension. |
Probably worth noting that (at least on the Sublime docs page) they do support this:
Seems like it might be unnecessary to add it as a full-fledged feature... |
Are we able to use regex ? If yes how ? Cause I'm not able to make it work.. With regex support yes it would be good enough. It would be nice if we could make custom variable like TM_FILENAME or simple shortcuts. |
We are tracking the transformations request in #6920. It's a little more complex because of how the regex-engines in TextMate and VS Code/JS work. We are likely not shooting for compatibility in evaluating them, but just reuse the syntax. |
Any update on being able to retrieve the file name without the extension? |
Is Date as listed in #4956 (comment) still a thing to come? |
@Aides359 How is |
@jrieken hm.. good point. In lack of this feature I currently use vscode-insertdatestring (which is quite a hassle since I have to execute two commands per snippet) and they solve this issue by setting a property in the user settings with a sensible default. Otherwise (not sure if that is possible syntax-wise) a solution might be to specify it using a parameter somewhat like |
@Aides359 Yes, we need this. I'm currently TRYING to fully replace my workflow from WebStorm to VS Code for all the good reasons but always end up coming back to WS for heavy duty coding sessions. I use As an example, creating
Should become:
|
@borislemke Is that a webstrom specific syntax, or where is that defined? |
@jrieken that is the proposal I would like VS Code to implement. The official WS syntax for the same template is:
|
+1 for date, unless the format is not configurable cause i'd just rage over anything not YYYY-MM-DD. |
I will add a vote for this as well. Having to add notes with dates by hand is wasting time. |
The documentation on snippets says:
Which implicitly says that VSCode does support variables.
The TextMate documentation on snippet variables says:
Though it does not work, nor does vscode seem to provide an alternative.
Steps to Reproduce:
-> Does not insert the selected text in place of $TM_SELECTED_TEXT
The text was updated successfully, but these errors were encountered: