Is possible to create a snippet that when expanded it insert a line in the start of the file? #383
-
I'm trying to create a snippet like this:
When I type |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Ouh, yeah that's possible: just create a functionNode without arg nodes. The code in there will only run once during the initial expansion and you won't see it as long as it s("dataclass", {
<other nodes>,
f(insert_dataclass_at_beginning, {})
}) This will be more straightforward once pre_expand/post_expand-callbacks are added. |
Beta Was this translation helpful? Give feedback.
-
Functions are evaluated withing the previews, I think better to use some kind of guard to avoid rewriting the line. |
Beta Was this translation helpful? Give feedback.
Ouh, yeah that's possible: just create a functionNode without arg nodes. The code in there will only run once during the initial expansion and you won't see it as long as it
doesn't return any textreturns an empty string.This will be more straightforward once pre_expand/post_expand-callbacks are added.