I would like to create files and apply snippets from an extension.
Expected process flow(All processes are done by extensions)
- retrieve the snippet
- create new file
- apply the snippet to the created file
- repeat steps 2~3
What I have done
- Create a custom snippet
custom.code-snippetsunder the .vscode folder. - Execute the created snippet from the command palette or from a text editor input.
- Build and run the extension
- Create files from the extension
- Retrieving the contents of a snippet file.
What I looked into
- Check for functions like
executeSnippet. - Check for functions like
vscode.TextDocument.insertText
There is a SnippetString in the API, so there seems to be a way to apply snippets.
Search VSCode API page with the word snippet
29hits
- 1~2 : CompletionItem
- on typing
- 3~4 : DocumentDropEdit
- on drop
- 5~7 : InlineCompletionItem
- on typing
- 8 : MarkedString
- have nothing to do with this issue.
- 9 : ProviderResult
- have nothing to do with this issue.
- 10~25 : SnippetString
- Use this to assemble snippets.
- 26~28 : TextEditor
- Processing "opened" documents
- 29 : WorkspaceConfiguration
- have nothing to do with this issue.
I could only find something that could do something about user behavior.
This is my first time developing a VSCode extension and I don't know how to do it. Can you just tell me which functionality I should use? If it's not possible, I'll give up and use Nodejs.