Emacs YASnippet Tip: Expand Whole hyphenated-word as Input

By Xah Lee. Date:

In YASNippet, you can define your own templates. For example:

(buffer-substring-no-properties START▮ END)

But sometimes your word contains a hyphen, but upon expansion, it uses only part of the word as input. For example, you want:

(buffer-substring START▮ END)

But you get:

buffer-(substring STRING▮ FROM &optional TO)

How to fix this?

Put the following in your init file:

;; 2011-07-29 yasnippet. Make the “yas/minor-mode”'s expansion behavior to take input word including hyphen.
(setq yas/key-syntaxes '("w_" "w_." "^ ")) ; default is '("w" "w_" "w_." "^ ") as of 2011-07-29

Thanks to João Távora. Source groups.google.com.

If you have a question, put $5 at patreon and message me on xah discord.
Or support me by Buy Xah Emacs Tutorial