0

When I want to add a snippet for the current language, I open the command palette, type "snippet", go "Configure Snippets", then I have to select the language even though the file I'm editing has a language selected. Is there a way to skip this step?

Obviously this isn't a big hurdle, but this step seems unnecessary so I'm wondering if someone's already thought of this, or if I should submit a feature request. Or, maybe there's a good reason this hasn't already been implemented, like if the snippet system is more complicated than I thought. (Best outcome is I learn more features of the tools I'm using :D )

Research

  • Command palette search for "snippet" only shows Configure, Insert, and Fill File
  • Keyboard Shortcuts search for "snippet" shows a few more like Surround and Show, but nothing that seems relevant
  • Searched repo for "label:snippets current language" but didn't see anything relevant, but there's a lot of results so I might have missed some

I'm using VSCodium 1.105.17075

1
  • I don't think there is buitt-in way to do that. You can bring up that QuickPick with a command but there is no way to input text there automatically. You can do this via an extension tat allows you to run the vscode api though. If you want to see that let m eknow. Commented Nov 11 at 19:52

1 Answer 1

0

The most relevant looking command I can see is workbench.action.openSnippets, which is just the command that opens the quick pick to select which snippet scope file to open. I'm going to guess from looking at the its signature at the time of this writing (which doesn't appear to take any arguments to specify a language identifier) that the answer is no, but I'd be happy to be wrong. Even if it did, if I recall correctly, keyboard shortcut args don't support variable expansion. And I'm not aware of a way to make keyboard shortcuts manipulate the contents of the input field of a quick pick (semi-related: Is there a keyboard shortcut command for typing specified text into input boxes (not the editor) in VS Code?).

Perhaps if you wanted this, you could raise a feature request asking for a new command to be added that does this.

Sign up to request clarification or add additional context in comments.

1 Comment

If anyone reading this ends up raising an issue ticket like I suggested, please either comment here with the link to it, or notify me in it with "@starball5" and a link to this Stack Overflow post so I can update it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.