Skip to content
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

Extend SnippyEdit to accept selection input and create snippet based it #146

Open
roylez opened this issue Dec 30, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@roylez
Copy link

roylez commented Dec 30, 2024

Problem Statement

I write my snippets myself most of the time, and even though SnippyEdit is handy opening snippet buffer for me, it could be even easier if it could template out new snippets for me.

Certainly I could put similar functionality together myself, but expand_snippet(snippet, word) does not take pre-fills, and I could not enable it to jump between stops.

Ideas or possible solutions

SnippyEdit could expand a snippet to create new snippets, and put the selected text in main content, i.e, $0.

The workflow should like:

  • :SnippyEdit entered
  • A choice of snippet files is presented, like what it is right now
  • Depending on the chosen snippet flavour, expand a built-in snippet and put the text selection as $0. For example
snippet ${1:trigger} "${2:descritption}"
  ${0:SELECTED TEXT}

Alternatives you have considered

Maybe it could have its own command, but having the function in SnippyEdit would be better.

@roylez roylez added the enhancement New feature or request label Dec 30, 2024
@dcampos
Copy link
Owner

dcampos commented Jan 11, 2025

This would certainly be handy on many occasions. Implementation-wise, SnippyEdit could take an optional range to determine the text to used for creating the snippet.

For the built-in snippet, we could either hard-code it or store it in a snippets/ folder within the plugin tree. The latter approach would make it easier for user to override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants