Jump to content
ssoriche

Configure snippet separators

Recommended Posts

I have a number of snippets that are short forms for standard commands, that don't occur in English, like `d` for `docker` and `g` for `git`. Overall these work quite well with very little conflicts. However words like `I'd` cause the `d` to expand to `docker`. It would be nice to be able to configure Alfred, either overall or per snippet, not to include `'` (single quote), `-` (dash), `_` (underscore) as word separators for use when expanding snippets.

Share this post


Link to post
Share on other sites

@ssoriche It looks like you've enabled "Expand snippets mid-string" in Alfred's Features > Snippets > Auto Expansion Options, so disable this to avoid the mid-string expansions you're seeing:
https://www.alfredapp.com/help/features/snippets/advanced/

 

I'm able to use 'd and 't as shortcuts and "I'd" doesn't trigger, as "Expand mid-string" is disabled.
 

Cheers,
Vero

Share this post


Link to post
Share on other sites
2 minutes ago, Vero said:

@ssoriche It looks like you've enabled "Expand snippets mid-string" in Alfred's Features > Snippets > Auto Expansion Options, so disable this to avoid the mid-string expansions you're seeing:
https://www.alfredapp.com/help/features/snippets/advanced/

 

I'm able to use 'd and 't as shortcuts and "I'd" doesn't trigger, as "Expand mid-string" is disabled.

 

Thank you for the response. It's definitely disabled. `I'docker ` still shows up.

 

Enabling: I'docker like to say it causes a difference but it doesn't

Disabled: I'docker like to say it stopped but it didn't

 

The other is `g ` to git, with disabled I can type `going ` and not get `goingit ` but when enabled `goingit `. So disabling is right (I forgot to turn it off there and ended up with `disablingit `), in that it won't expand when I'm typing words. But either way I still get:

 

`_d ` ==> `_docker `

`:d ` ==> `:docker `

`'d ` ==> `'docker `

`I'd ` ==> `I'docker `

 

So it looks like "Expand snippets mid-string" takes into account other letters as to whether the expansion should occur or not, but other punctuation characters are not. I know TextExpander has the ability to specify the punctuation that's included when determining word boundaries.

Share this post


Link to post
Share on other sites

Maybe this is a bug. Today I added another snippet `;dd`, which just returns the date without formatting (20190401), but I have another which is `;ddate` to return the date with formatting. I can no longer access the `;ddate` snippet. Once I've completed the second `d`, the snippet is being expanded automatically. Expand snippets mid-string is definitely not checked.

Share this post


Link to post
Share on other sites
28 minutes ago, ssoriche said:

Once I've completed the second `d`, the snippet is being expanded automatically.

 

That's exactly how snippets are intended to work; Once you've typed the entirety of the snippet, it will be expanded. 

 

If you want the keyword to include a space at the end, so that you must type ;dd[space], then add the space as a suffix to the collection, or at the end of your snippet keyword.

 

Expand snippets mid-string refers to the keyword being typed not at the beginning of a set of characters, e.g. if your keyword is "ptime" but you type "uptime", "ptime" will only expand to your assigned snippet if mid-string expansion is enabled. 

 

I'd encourage you to take a look at the tips on choosing good keywords for snippets here:

https://www.alfredapp.com/help/features/snippets/#tips-expansion

 

Cheers,
Vero

Share this post


Link to post
Share on other sites

Thank you for the quick reply yet again, your support has been amazing.

 

Ok, that makes sense, it still is breaking on `I'd` expanding out to `I'docker`. Is it possible to use different characters and non-printable characters as separators? For instance for `d` being `docker` I'd like to say if the letter d is proceeded by space or no-character and followed by space or enter, expand. The same goes for `;dd` example above, `;dd` followed by space or enter should expand, not just followed by space.

 

 

~Shawn

Share this post


Link to post
Share on other sites

@ssoriche I'm afraid those are quite unsuitable keyword choices as "I'd" is something you'll type many times a day, assuming I'm seeing that correctly, and it's "I'd" as in "I'd like a coffee, please"? 

 

As with the tips in the link I provided, either prefix your keyword with an unusual non-alphanumeric character, (e.g. !date or \\time) and keep it to something that's easy to reach on the keyboard and type. At this point, your suffix or last character needs to be specified.

 

Cheers,
Vero

Share this post


Link to post
Share on other sites

@Vero Sorry, I have `d` as a stand alone letter as a shortcut, as `d` on its own does not occur very often. However with `d` the word `I'd` triggers the shortcut, which is undesirable.  Space followed by `d` doesn't work as on the command line, it would be the first character typed. Therefore what I'm asking is there a better way to set acceptable prefixes and suffixes to a snippet? I'd like to make a list like no proceeding character, enter, space. This is something that a regular expression could handle, but I don't think there's an interface to supply them to snippets.

 

Thank you again.

~Shawn

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...