Emacs YASnippet Tip: Expand Whole hyphenated-word as Input

By Xah Lee. Date:

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

bsnp▮
  ⇓
(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▮
  ⇓
(buffer-substring START▮ END)

But you get:

buffer-substring▮
  ⇓
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.

Liket it? Put $1 at patreon. Or Buy Xah Emacs Tutorial. Thanks.