4

Q: how can I get yasnippet snippets to expand when placed immediately after punctuation?

Consider the snippet SNIP. It will expand if preceded by whitespace (eg, here's a SNIP expands), but not when preceded immediately by an alphanumeric character (eg, here's a superSNIP does not expand).

Snippets also expand after parentheses and braces, so these all expand:

  • here's a (SNIP
  • here's a [SNIP
  • here's a {SNIP

However, snippets do not seem to expand after punctuation, so, eg, neither here's a ;SNIP nor here's a .SNIP will expand.

I imagine there's a good reason for this, but I'd like to know how to get snippets to fire after punctuation characters (or, more generally, non-alphanumeric characters). Ideally, this could be mode-specific or buffer-local.

  • 1
    Perhaps your major-mode defines the period as having a certain syntax that is not contemplated by yas-key-syntaxes ["List of character syntaxes used to find a trigger key before point.]? The default value is: (list "w" "w_" "w_." "w_.()" "^ ") Check the syntax value of the period in your particular major mode by placing the cursor at that position and typing C-u C-x = If appropriate, you could try adding that particular syntax to the list above. [This is all just a guess.] – lawlist Feb 4 '15 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.